Coding Standards Article

I stumbled on this today and read the whole article. Great read when you want to wake up in the morning!

Funny enough, as I was looking through the tutorials yesterday I noticed the convention of the spaces after a class name but before the semi-colon. I actually pondered why they were not all the same spacing.

The convention says 2-3 spaces.

Out of the whole document I read today, it’s really plain as day why you are doing these things. Thought I would just share something that my mind completely OCDd on and can’t let go of.

What. Does. This. Mean? :slight_smile: 2-3 spaces after class name? Why not 2 OR 3?

Seriously though, just curious where this one came from. </end light heart post>

The only reason I can think of is that it has something to do with automatically generating documentation. It obviously has no meaning at all for the code itself.

1 Like

When I write a class with inheritance I always press tab after the class name which adds 1 - 4 spaces to get to the next tab alignment:

class AB    :   public Component {}
class ABC   :   public Component {}
class ABCD  :   public Component {}
class ABCDE :   public Component {}

class ABCDEF    :   public Component {}

Not sure why JUCE uses 2 - 3, maybe for similar reasons?

The reasoning is to move everything possibly not interesting out of the focus. So leaving “a bit more” space after the class name makes it stand more out.

Sure, one can start now the debate, if the classes you derive from are not actually quite important… I think there are different opinions about that.

We do tabs usually only on following lines, not from block to block…

That’s probably the rule that allows most freedom, everybody needs room to be creative :stuck_out_tongue:

1 Like

Got it! 2-3 spaces is “a bit more spacing for focus”, that is all I needed to know. :slight_smile: