Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Object-oriented programming languages have evolved to incorporate all sorts of design practices so that developers are empowered with the tools they need to create large, rich, and efficient applications in as little time as possible. Subclassing is one of the design foundations that have made this achievable. Before diving into coding a project, we recommend that you draw out your class design and look for opportunities to employ subclassing, clusters, and categories. The take-home points for these class extension strategies are as follows:
If you want to add new instance variables to a class or override a method of a class, use subclassing.
If you want to hide the implementation of a class, simplify a class’s interface, or incorporate more code reuse, create a class cluster.
If you want to add a method to a class, create a class category.