17
Wombat
7y

When it comes to the indentation or look I am fully consistent.
But when it comes to naming I am inconsistent like a crack whore telling she's clean.
Camelcase, underscores inconsistent variable and function names. I use all of them within a single file. On some days I even switch languages.
I truly am miserable in code consistency. Is there any good advice to keep the code consistent?

Comments
  • 6
    Tools telling you your mistakes.
  • 4
    @CWins tell me more.
  • 3
    Use an IDE
  • 4
    @Divisionbyzero
    I'm using vs and c#, so for me there are roslyn analyzers for style and technical mistakes. They tell me "hey, your naming here sucks, you didn't check that parameter for null and that var is never used" and a lot more.

    After some time with those tools, i do it right as a habit.

    I can't tell you what's equivalent for your technologies, but others here can.
  • 3
    @CWins nice to hear, that there are tools for this. I didn't know.
  • 1
    Pick a style and stick with it! Keep correcting yourself whenever you see the naming mistake and soon you'll find yourself only using that one type of naming scheme.
  • 1
    @tisButABug yesterday I did some javascript in which I started all variables with a dollar sign because Ive been doing quite a lot of PHP lately.
  • 3
    @Codex404 I've seen some guy using this style at SO. That was awkward.
  • 1
    @Divisionbyzero it was indeed when I noticed, first thing I did was redo everything.
  • 3
    @Codex404 gladly I'm not that inconsistent. 😅

    I mostly have problems when switching languages, too. I write other PHP than I write JS. And actually I stick more to the "rules" in frontend. Cause people could see it... 😅
Add Comment