A lot of personal factors are in play in the world of software engineering, and a lot of the time they can interfere with the long term goal of getting stuff done. More recently in my career I have been far more pragmatic about how I look at code and trying not to get too involved in discussions about things that don't actually matter. There are many such discussions to be had: single return statements at the end of a function bodies, whether or not the use of the ternary operator is allowed, whether to comment code more thoroughly or less thoroughly, and one of my favourites: indented braces. For the slightly uninformed, a discussion about "indented braces" normally revolves around which of the following three (or more) styles to use when defining a new sub-block in code. For example, most examples seem to prefer putting the brace on a new line, and indenting the code, as follows: function MyFunction() { // This is code } In the above example, indented code clearly identifies a new scope. An alternative is to indent the braces as well, as follows: function MyFunction() { // This is code } In the above example, a set of indented braces is responsible for clearly identiying a new scope. The braces are indented with the code. Another alternative is seemingly an attempt to reduce the number of lines of code (and thus make it more readable because more fits on a screen) by having the first brace on the same line, as follows: function MyFunction() { // This is code }I have worked in many places, and I have had to use all three styles. Every time I had to change to a new style, it was to meet some set of coding guidelines. I was never happy about doing so because, well, let's be frank: it involved change. It involved doing something differently to the "perfect" way that I had previously done it for years, "just" to meet someone's expectations. I'm being challenged on what I know and asked to comply with idiots. Do you see the personal factors at play here? My job is to design and implement software solutions, but I'm having a panic attack regarding my entire sense of self worth. Doesn't that seem a bit overkill to you? It's surprising that for a job requiring so much applied logic, I'm fussing over something illogically. The honest truth about it all is that the style of bracing doesn't really matter. Every style has its benefits and drawbacks. One uses less lines, which makes it so that more code fits inside the window. It is therefore a useful style to use when code needs to be understood without scrolling around. The other styles may require less cognitive burden when trying to realise what scope bits of code are in (I don't really know for sure). So, in a small way, it does matter. But, only a tiny amount. It doesn't affect how correct my code is, nor does it affect anything except my personal ego, so why not drop the issue and move on? That's right, I'm suggesting that it simply doesn't matter. Nick
|