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 2. Factory Method Pattern > Key OOP Concepts Used in the Factory Method...

2.7. Key OOP Concepts Used in the Factory Method Pattern

Incorporating changes that were not anticipated in the original software design can sometimes require changes to existing code. Modifying existing code that works well should be avoided if at all possible as it can result in unintended consequences such as the introduction of new bugs. A slight change in a dependant module can result in breaking a program in several places if there's tight coupling between code segments.

Code that handles change well is possible using good OO design. The factory method pattern is an excellent solution to this recurring requirement. The factory method pattern is a solution to one of the most common reasons for tight coupling, which is caused by one class instantiating another class and using the resultant object. Of course, classes need to be instantiated – there's no way to write code that does not instantiate classes. So, what are we talking about?


  

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