3 ms·
This is one of my most loathed developments in "best practices" lately. I see it everywhere and it just adds noise, since it doesn't change the functionality o
by zackmorris 13y ago
This is one of my most loathed developments in "best practices" lately. I see it everywhere and it just adds noise, since it doesn't change the functionality of the code. It's like adding a comment on every flow control statement. A concrete example is try/catch, which forces the user to add superfluous curly brackets.
In fairness, I have hit the "goto" style of bug he talks about in switch commands, when I forgot to add a break statement. But I can't remember a single time in my programming career when I added a line to an if/for/while and broke something.
I think people are wasting their energies on subjective topics like telling people to use spaces instead of tabs, or putting { on the same line as the flow control statement, or even telling people how much whitespace to use between () and where.
What we really need is a standardized formatter for any language that works like Google's Go Format. Programmers should not be spending time refactoring code just for looks. If anyone knows of a utility that does this and is easily configurable for personal taste, I would sure appreciate it. Being able to convert /* */ comments to // and back again would be a plus.
- nostrademons 13y agoFormatters are usually language-specific, and there are formatters for most popular languages. See eg. clang-format [1] for C/C++, your IDE's reformat command for Java [2][3], PythonTidy [4] or AutoPep8 [5] for Python, or jsbeautifier [6], JSPretty [7], or Aptana [8] for JS. [1] http://clang.llvm.org/docs/ClangFormat.html http://clang.llvm.org/docs/ClangFormat.html [2] http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fpreferences%2Fjava%2Fcodestyle%2Fref-preferences-formatter.htm http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclips... [3] https://www.jetbrains.com/idea/webhelp/reformatting-source-code.html https://www.jetbrains.com/idea/webhelp/reformatting-source-c... [4] https://pypi.python.org/pypi/PythonTidy/1.22 https://pypi.python.org/pypi/PythonTidy/1.22 [5] https://pypi.python.org/pypi/autopep8/ https://pypi.python.org/pypi/autopep8/ [6] http://jsbeautifier.org/ http://jsbeautifier.org/ [7] http://www.jspretty.com/ http://www.jspretty.com/ [8] http://www.aptana.com/products/studio3 http://www.aptana.com/products/studio3
- benihana 13y ago>I see it everywhere and it just adds noise, since it doesn't change the functionality of the code. I'm confused. It sounds like you're saying if (condition) { stuff(); other_stuff(); } is the same as if (condition) stuff(); other_stuff(); because the brackets don't change the functionality, but they do. I might be misreading what you're saying though.
- detrino 13y agoWhat he was saying should be obvious, since there is actual code in the comment he was replying to, and its not what you wrote.