Norway


On the Stitcher.io they’ve shared a post that makes some suggestions about where a curly brace belongs and how that might differ from situation to situation.

Dedicating a whole blogpost to brackets might seem like overkill but I believe it’s worth thinking about them. Not just because of one , but because there’s a bigger message in all this. Thinking about how we read and write code not only improves the quality of that code, it also increases our own and others ease of mind when working with it. It can improve the fluency of your work and free your mind to think about important stuff.

[…] I wrote about visual code improvements a while back in a previous blogpost about cognitive load. Today I want to focus on that one little, yet very important character in our codebase: the curly bracket. More specifically, we’re only going to look at the opening curly bracket, because there’s little to no discussion about the closing one.

The post goes on to show several different example situations and where they think the "most correct" placement for the curly brace is. They alos talk about the between their use on constructors versus control structures. The main recommendation, however, is to keep things consistent across the codebase.



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here