Chapter 18. Prototype

When you develop a class, you ordinarily furnish it with constructors to let client applications instantiate it. In some circumstances, you may decide to isolate users of your class from directly calling a constructor. The construction-oriented patterns covered so far—BUILDER, FACTORY METHOD, and ABSTRACT FACTORY—all provide this isolation. These patterns establish methods that instantiate an appropriate class on a client's behalf. The PROTOTYPE pattern also conceals object creation from clients, but uses a different approach. Instead of bringing forth new, uninitialized instances of a class, the intent of the PROTOTYPE pattern is to provide new objects by copying an example.

Prototypes as Factories

Suppose that you are using ...

Get Design Patterns in C# now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.