Creational pattern

Generation pattern (English creational patterns ) are a subset of design patterns in the field of software development, which serve to create objects. They decouple the design of an object from its representation. The object creation is encapsulated and outsourced (eg in a factory ), to keep the context of object creation independent of the concrete implementation, according to the rule: " Program the on the interface, not the implementation "

Design patterns include two ideas: The first is to hide the knowledge of the concrete classes, it hides the second, how to generate and connected instances of these classes.

Design patterns are divided into object design pattern classes and design patterns. The former deal with design patterns that have to do with the object creation and left parts of the object generating other objects. The latter have to do with the class instantiation and leave the class instantiation subclasses.

Example of a production pattern

If instead of

Factory factory = new Account Account Account Factory ();      type = KontoFactory.GIRO;      account = kontoFactory.getInstance (type); obtained ( here checking account ) to determine at run time rather than having to commit themselves already to translation time on the concrete class, the flexibility, the class of the object to be created.

The reasons for the decoupling of construction and representation of an object are different depending on the generation pattern:

Brief description and delimitation of different production patterns

Abstract Factory ( abstract factory )

The Abstract Factory defines an interface for creating a family of objects, the concrete classes of generated objects are determined at runtime.

Single piece ( singleton )

From one class only once to be produced object, for example, because a central structure intended to be enforced or a corresponding hardware component physically exists only once.

Builder ( builder )

The design pattern Builder separates the construction of complex objects of its concrete representation. This will secure that the same construction process can create different representations.

Factory Method ( factory method)

Several related types of objects (classes) implement the same interface, but differ in name and purpose. Now a concrete object of a specified type should be used in a program context.

Multitone

Variant of the Singleton pattern, which controls the number of generated objects to reduce to a value required for a good overall performance, for example by the number of simultaneously open database connections.

Prototype (prototype )

The prototype design pattern used as an object template (prototype ) in order to produce therefrom further objects, which may be subsequently modified.

Credentials

315690
de