본문 바로가기
James Cooper - Python Programming with D

Summary of Creational Patterns

by 자동매매 2023. 3. 23.

11**

Summary of Creational Patterns

  • The Factory pattern is used to choose and return an instance of a class from a number of similar classes, based on data you provide to the factory.
    • The Abstract Factory pattern is used to return one of several groups of classes. In some cases, it actually returns a factory for that group of classes.
      • The Builder pattern assembles a number of objects to make a new object, based on the data with which it is presented. Frequently, the choice of which way the objects are assembled is achieved using a factory.
  • The Prototype pattern copies or clones an existing class instead of creating a new instance when creating new instances is more expensive.
    • The Singleton pattern is a pattern that ensures that there is only one instance of an object and that it is possible to obtain global access to that one instance.

Part III Structural Patterns

Structural patterns describe how classes and objects can be combined to form larger structures. The difference between class patterns and object patterns is that class patterns describe how inheritance can be used to provide more useful program interfaces. Object patterns, on the other hand, describe how objects can be composed into larger structures using object composition, or the inclusion of objects within other objects.

For example, we’ll see in this section that the Adapter pattern can be used to make one class interface match another, to make programming easier. We’ll also look at a number of other structural patterns where we combine objects to provide new functionality. The Composite pattern, for instance, is exactly that: a composition of objects, each of which may be either a simple object or itself a composite object. The Proxy pattern is frequently a simple object that takes the place of a more complex object that can be invoked later, such as when the program runs in a network environment.

The Flyweight pattern is a pattern for sharing objects, where each instance does not contain its own state, but stores it externally. This allows efficient sharing of objects to save space, particularly when there are many instances but only a few different types.

The Façade pattern is used to make a single class represent an entire subsystem, and the Bridge pattern separates an object’s interface from its implementation so that you can vary them separately. Finally, we’ll look at the Decorator pattern, which can be used to add responsibilities to objects dynamically.

You’ll see that there is some overlap among these patterns and even some overlap with the behavioral patterns in Part IV, “Behavioral Patterns.” We’ll summarize these similarities after we describe the patterns.

'James Cooper - Python Programming with D' 카테고리의 다른 글

The Bridge Pattern  (0) 2023.03.23
The Adapter Pattern  (0) 2023.03.23
The Prototype Pattern  (0) 2023.03.23
The Prototype Pattern  (0) 2023.03.23
The Singleton Pattern  (0) 2023.03.23

댓글