Chapter 20. Lessons from Design Patterns: Factories

Overview

This chapter discusses the use of factories—objects that make other objects. Although factories are presented in the Gang of Four book, their use in design is not discussed fully.

This chapter

•   Discusses why the use of factories can greatly simplify your design and code.

•   Explains the proper steps of seeing first what your objects are and then deciding how to create and/or manage them.

Factories

Usually, when I am designing objects, I am concerned with their behavior: what the objects do and how other objects tell them to do it. But I also need to be concerned about figuring out when a ...

Get Design Patterns Explained: A New Perspective on Object-Oriented Design, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.