From the course: Design Patterns: Creational

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

The Prototype pattern

The Prototype pattern

From the course: Design Patterns: Creational

Start my 1-month free trial

The Prototype pattern

- [Instructor] Prototype is a creational pattern, so, as with other creational patterns the goal is to encapsulate the process of creating new objects. But compared to the creational patterns we've looked at so far in this course, the Factory patterns and the Builder pattern. But compared to the creational patterns we've looked at so far in this course, the Factory patterns and the Builder pattern, the Prototype pattern is quite different. With Prototype we encapsulate the process of creating new objects inside an object we call the prototype object. And we create new objects of the same kind by cloning, meaning copying, that prototype object. Let's take a look at the intent of the pattern. With the Prototype pattern we specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype. What is a prototypical instance? That's an object we've created that will be used…

Contents