Hey everyone!

Let’s kick off this blog with a topic which probably isn’t going to be solved for aeons! 🙂

Since it’s going to be mostly about iOS development, I will focus on Objective-C/Swift here. You may have noticed that even Apple changes its mind regarding braces rules over the years.

As far as I can remember, almost 4 years ago, the simple template for initialisation method looked something like this:

I don’t know about you – but at the first glance, my OCD had noticed one inconsistency in the code above. So, either put the curly bracket from line 2 into the first line or put the curly bracket from line 4 into a new line. Yes, I’m aware that Apple was consistent in this inconsistency by always putting bracket in a new line after they would start a method and cuddle inside a method. I couldn’t live with that. So I’ve always manually transformed the method above to:

I’ve done this for the past few years and then Apple introduced Xcode 6 and Swift. First thing I’ve noticed after creating a new Objective-C template was that newline braces were completely gone. Looking at Swift tutorials – no newline braces either! Although the init method is no longer present in their templates, they have finally decided for:

I had to stop at this point and think about it. I’ve tried to help myself by using Google a bit to see what other people think about the topic. It didn’t help much, since people are saying reasonable things in both directions (although the debates were more general than platform specific).

But there was one eye-opener I didn’t think about before. Cuddly braces are more logical, since they actually belong to a statement which opens them. Similar way of thinking is found in standard writing grammar. If you announce a list of items, you probably aren’t going to put the colon symbol into a new line!

In the end, after almost 4 years of newline formatting, I’ve decided to cuddle – for 3 pretty strong reasons (ordered by strength!):
1. It’s logical!
2. It makes classes end up with 20% – 30% less lines of code and therefore improves readability.
3. Apple uses it. I don’t want to waste (any more) time to “fix” their cuddly autocomplete.