Please enable JavaScript.
Coggle requires JavaScript to display documents.
Programming design patterns design-pattern-big1 - Coggle Diagram
Creational patterns
Provides the interface for creating families of related objects without specifying their certain classes.
Factory method
When to use
When the system shouldn’t be dependent on a process of creation of objects and should be expandable.
When required, a base class has to delegate the creation of objects to derived classes.
-
Participants
Creator (abstract class/interface) - Defines an abstract factory method which returns a new Product object.
-
-
-
Defines the interface for some object creation but the decision what type of class will be created makes a heir class. Base class delegates the creation of objects to derived classes.
The example is in the “Factory method” project.
LINK
Abstract factory
Provides the interface for creating families of related objects without specifying their certain classes.
The example is in the “Abstract factory” project.
LINK
-
Participants
Factory(abstract class/interface) - Defines methods for creating objects. The methods return abstract product objects, not certain implementations.
SpecificFactories(implementations of Factory) - Implements abstract methods from the basic class and defines which certain objects to use.
Products(abstract classes/interfaces of products to be created) - Some abstract objects to be created.
-
Builder
Participants
Director - Disposer - makes an object, using builder objects.
-
-
-
Encapsulates creation of an object and allows separate it to varied stages.
The example is in the “Builder” project.
LINK
When to use
-
When the creating process of an object shouldn’t be dependent on what parts the object consists of and how these parts are related.
Prototype
Allows to create objects based on earlier created objects.
The example is in the “Prototype” project.
LINK
When to use
-
When it is not desirable to create a hierarchy of factories for creating product-objects from parallel classes hierarchy.
-
Participants
Prototype (abstract class/interface) - Defines the interface to clone itself. Defines the method IPrototype Clone(); which must be implemented in derived classes.
-
.Net provides the functionality for cloning by MemberwiseClone. However it should be counted that reference types wouldn’t be copied instead of the object copy it makes the copy of the link. To resolve it the deep copy must be used.
Singleton
Ensures that only one object of a certain class will be created and gives the entry point to that object.
The example is in the “Singleton” project.
LINK
When to use
When required only one instance of a certain class is created. If the instance exists Singleton returns this existing instance.
Structural patterns
-
Behavioral patterns
-