Hacker News new | ask | show | jobs
by noir_lord 3716 days ago
Change a variable name, yes absolutely depending on context and the language in use, this can range from using foo_bar/fooBar through to inappropriate variable names (I've seen swearwords used as variables when someone has been doing debugging in code and needed to grab intermediate values, seeing "cunt is undefined" in the console is not going to do you any favours on the professional scale) or ones that lack clarity.

Prohibit lines longer than N chars, again absolutely, many languages have standards like Pythons PEP8, I find 80 chars constricting sometimes but I stick to the standard because it is the standard (de-facto or not).

--

I stick to standards where they exist, for PHP thats the relevant PSR's, for Python, PEP8.

I enforce it by using the IDE to flag non-conformance and auto format either on the fly or on save, since I'm the only dev I don't need to enforce it on commits/pull requests.

Style Reviews are not applicable since there is just me (see above).

I think coding against the languages 'default' styles whether de-facto or imposed (I wish all languages had gone the gofmt route so we could obviate this problem nearly completely) helps, it certainly requires less context shifting when jumping from code I wrote to third party libraries in the same language.

In the past when I've worked with teams I've found having a defined standard helps hugely since it settles the inevitable bikeshedding arguments that crop up when programmer A wants to do foo and B do bar, often there is no clear winner so just picking one and adding it to the standard kills the argument dead the next time.

Personally I've always preferred :-

    if foo()
    {
        stuff();
    }
to

    if foo(){
        stuff();
    }
but since PSR2 says not to do that I stopped (or more correctly I let the IDE handle it till it became habit to do it PSR style).