Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Summary

This chapter is about writing comments that pack as much information into as small a space as possible. Here are the specific tips:

  • Avoid pronouns like “it” and “this” when they can refer to multiple things.

  • Describe a function’s behavior with as much precision as is practical.

  • Illustrate your comments with carefully chosen input/output examples.

  • State the high-level intent of your code, rather than the obvious details.

  • Use inline comments (e.g., Function(/* arg = */ ... ) ) to explain mysterious function arguments.

  • Keep your comments brief by using words that pack a lot of meaning.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint