SlideServe
Menu
Préférences
© SlideServe · v2026

Prototype Pattern

stockton-gavyn avatar
12 diapositives · 408 Views · Nov 20, 2014

Prototype Pattern. Yiqiang Song 2/2/09. Prototype Pattern. A creational pattern Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype. Problem. Prototype solution. Prototype Pattern UML. Participants: • Prototype

Prototype Pattern - slide 1
01 / 12Prototype Pattern
1 / 17

Télécharger la présentation

Prototype Pattern
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Prototype Pattern Yiqiang Song 2/2/09

  2. Prototype Pattern • A creational pattern • Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype

  3. Problem

  4. Prototype solution

  5. Prototype Pattern UML Participants: • Prototype o declares an interface for cloning itself. • ConcretePrototype o implements an operation for cloning itself. • Client o creates a new object by asking a prototype to clone itself.

  6. ExampleAnimal farm

  7. Prototype Pattern Example code

  8. Prototype Pattern Example code

  9. Prototype Pattern Example code

  10. Prototype Pattern When to Use • When product creation should be decoupled from system behavior • When to avoid subclasses of an object creator in the client application • When creating an instance of a class is time-consuming or complex in some way.

  11. Consequences of Prototype Pattern • Hides the concrete product classes from the client • Adding/removing of prototypes at run-time • Allows specifying new objects by varying values or structure • Reducing the need for sub-classing

  12. Drawbacks of Prototype Pattern • It is built on the method .clone(), which could be complicated sometimes in terms of shallow copy and deep copy. Moreover, classes that have circular references to other classes cannot really be cloned.