Hacker News new | past | comments | ask | show | jobs | submit login

Prophet says:

Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.

And I think I kinda agree with this.




I do agree that there comes a point where you can get over zealous with indentation, but 3 levels deep is pretty common. In fact you idle at one level of indentation just with having your code inside a function. So basically all you need is one conditional inside a loop and you're already maxed out.


Probably not good for ruby when combinations of the following things can result in deeply nested code:

    module
      class
        def
          if
        class << self
          def


Well, the Prophet is a C programmer so his numbers may need adjustment by some constant for languages with objects, namespaces, modules, etc.

But still excessive indentation is a hint that the code may benefit from some refactoring.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: