kodecocodes / objective-c-style-guide

A style guide that outlines the coding conventions for Kodeco
http://www.raywenderlich.com/62570/objective-c-style-guide
3.1k stars 626 forks source link

Should we indent with 2 spaces? #4

Closed ColinEberhardt closed 11 years ago

ColinEberhardt commented 11 years ago

I know that 4-space is generally more popular than 2-space, however, I think this code style should reflect the fact that the code we are writing will be reproduced in blog posts, tutorials and books where there are significant restrictions on page-width.

When writing iOS 7 by tutorials there were significant wrapping issues (due in part to Apple's verbose naming conventions!).

I would like to propose the use of 2-space indentation in order to reduce the need to wrap lines when reproducing code within articles.

gregheo commented 11 years ago

:+1:

I code with two-space indentation all the time so I'm in. My own personal preference aside though, I think our page width restrictions are a good practical reason.

hollance commented 11 years ago

I'm OK with 2 spaces for the book but I find 4 spaces reads much easier and on the website there's less concern for wrapping because you can scroll the code blocks.

That said, we should just use a tool to reformat code according to these guidelines before putting them into the tutorials. That way authors can simply write in the style they want and the tool will fix everything up.

funkyboy commented 11 years ago

I agree on this. A script can take care of indentation. Maybe we need one also for curly braces?

method {} vs method { }

Cesare Rocchi studiomagnolia.com

On Nov 7, 2013, at 7:07 PM, Matthijs Hollemans notifications@github.com wrote:

I'm OK with 2 spaces for the book but I find 4 spaces reads much easier and on the website there's less concern for wrapping because you can scroll the code blocks.

That said, we should just use a tool to reformat code according to these guidelines before putting them into the tutorials. That way authors can simply write in the style they want and the tool will fix everything up.

— Reply to this email directly or view it on GitHub.

ghost commented 11 years ago

There are tools that handle this already, so no need to write a script. But if you think 4 spaces is nicer than 2, well I have to rethink everything I've ever thought about you, hollance. ;)

hollance commented 11 years ago

I can't be held responsible for what other people think about me. :-)

And yes, I meant using one of the existing pretty printer tools.

rwenderlich commented 11 years ago

+1 vote for 2 spaces, as I think it is better for our purposes on raywenderlich.com (conserving space in print/books so we have as little line wraps as possible, which waste space, don't look good, and are harder to read). I put a pull request for this, but if we decide to go forward with this a bunch of the examples in the guide will need to be switched from 4->2 as well.