More notes on “Effective C++”

23 April, 2009 § 1 Comment

This is the fourth post in a series of posts that I started after I finished reading Effective C++ by Scott Meyers. Previously covered were parts three, two, and one.

Item 31: Minimize compilation dependencies between files.
Using the pimpl idiom (“pointer to implementation”) you can truly separate the implementation from the interface. Omaha, aka Google Update, uses the pimpl idiom within the CUP implementation. This allows any client of CupRequest to have a lightweight object and be divorced from implementation details of CupRequest. If CupRequestImpl ever changes, any clients of CupRequest won’t have to recompile, allowing build times to be shorter.

Item 34: Differentiate between inheritance of interface and inheritance of implementation.
The easiest way to differentiate between interfaces and implementations is to declare your interfaces with a naming convention like IInterface. For example, this way you can clearly see that a class is enumerable because it implements IEnumerable, yet if the class inherits SortedArray, then you know that it extends an implementation of a SortedArray.

Item 39: Use private inheritance judiciously.
Sometimes classes have virtual functions that need to be overridden, this should be the only case for using private inheritance. Private inheritance is not the same as public inheritance. Public inheritance is usually referred to as an ‘is-a’ relationship, where you can say that the derived is an extension of the base class. Private inheritance simply tells implementation details, similar to a ‘has-a’ relationship.

Item 48: Be aware of template metaprogramming.
I had never heard of template metaprogramming (TMP) before this Item. This looks to be really interesting, and I’m looking forward to reading C++ Template Metaprogramming written by the Boost organization.

After reading Effective C++, I’m looking forward to using more of the STL, and getting my feet wet with TR1, Boost, and TMP. I would highly recommend reading Effective C++ for an experienced developer that is working in C++. This book is also good for students just getting in to C++, as it can help them watch out for many mistakes that novices and intermediate level developers may make.

Tagged: , , , ,

§ One Response to More notes on “Effective C++”

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

What’s this?

You are currently reading More notes on “Effective C++” at JAWS.

meta

%d bloggers like this: