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
Share this Page URL
Help

Chapter 14. Choosing between Inheritance... > Choosing a Technique for Code Reuse

Choosing a Technique for Code Reuse

In this section, I will discuss the relative advantages and disadvantages of using inheritance and composition. Both relationships are client-server relationships. A derived class is a client of the base class, and the base class is a server of the derived class. A composite class is a client of its component class, and the component class is a server of the composite class. This means that you are going to see significant similarities between C++ programs built with alternative design techniques.

The common feature of different design solutions is the division of work between the client and the server classes, be it with the use of composition or any other design techniques. This means that the server class has to be implemented before the client class can be designed. Hence, the techniques, which are discussed in this section, can be used both for program development and for program evolution.


  

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