Eloquent ruby

Chapter 1 - write code that looks like ruby

  • Code should be crystal clear - good code tells the reader exactly what it is trying to do. Great code shouts its intent.
  • Since there is a limit to how much information you can keep in your head at any given moment, good code is not just clear, it is also concise. It’s much easier to understand what a method or a class is doing if you can take it all in at a glance.
  • If it’s obvious how someone would use your method—if the class or program needs no explanation—then don’t explain it.
  • The danger in comments that explain how the code works is that they can easily slide off into the worst reason for adding comments: to make a badly written program somewhat comprehensible.
    • Is there anything you can do to let the code speak for itself instead of needing subtitles?
    • Remember, good code is like a good joke: It needs no explanation.

results matching ""

    No results matching ""