O'Reilly logo

Design Patterns in C# by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required