Code Complete

Fell in love with this fascinating book by Steve McConnell. Its a gem.

Highlights –

  • A key to being an effective programmer is maximizing the portion of a program that you can safely
    ignore while working on any one section of code. Classes are the primary tool  for accomplishing that objective.
  • Benefits of Using ADTs
  • You can hide implementation details
  • Changes don’t affect the whole program
  • You can make the interface more informative [say rather than style=0x02]
  • Easier to improve performance [corollary of #2]
  • Program becomes more self-documenting
  • You dont have to pass data all over your program
  • Good Class Interfaces





  • The first and probably most important step in creating a high quality class is
  • creating a good interface.
  • Provide services in pairs with their opposites.Most operations have corresponding, equal, and opposite operations. If you have an operation that turns a light on, you’ll probably need one to turn it off. If you have an operation to add an item to a list, you’ll probably need one to delete an item from the list.

  • Move unrelated information to another class

  • Don’t add public members that are inconsistent with the interface abstraction.




    Each time you add a routine to a class interface, ask, “Is this routine consistent with the abstraction provided by the existing interface?”

  • Abstraction helps to manage complexity by providing models that allow you to ignore implementation details. Encapsulation is the enforcer that prevents you from looking at the details even if you want to.

  •  Favor read-time convenience to write-time convenience
     Code is read far more times than it’s written, even during initial development.
     Favoring a technique that speeds write-time convenience at the expense of read-time convenience is  a false economy. This is especially applicable to creation of class interfaces. Even if a routine doesn’t   quite fit the interface’s abstraction, sometimes it’s tempting to add a routine to an interface that would be convenient for the particular client of a class that you’re working on at the time. But adding
    that routine is the first step down a slippery slope, and it’s better not to take even the first step.

  • It ain’t abstract if you have to look at the underlying implementation to understand what’s going on.

    —P.J. Plauger



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: