본문 바로가기

James Cooper - Python Programming with D14

The Bridge Pattern 13 The Bridge Pattern At first sight, the Bridge pattern looks much like the Adapter pattern in that a class is used to convert one kind of interface to another. However, the intent of the Adapter pattern is to make one or more classes’ interfaces look the same as the interface of a particular class. The Bridge pattern is designed to separate a class’s interface from its implementation so that y.. 2023. 3. 23.
The Adapter Pattern 12** The Adapter Pattern The Adapter pattern is used to convert the programming interface of one class into that of another. We use adapters whenever we want unrelated classes to work together in a single program. The concept of an adapter is thus pretty simple; we write a class that has the desired interface and then make it communicate with the class that has a different interface. There are t.. 2023. 3. 23.
Summary of Creational Patterns 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 n.. 2023. 3. 23.
The Prototype Pattern 10** The Prototype Pattern The Prototype pattern is used when creating an instance of a class is very time consuming or complex in some way. Instead of creating more instances, you make copies of the original instance and modify the copies as appropriate. Prototypes can also be used whenever you need classes that differ only in the type of processing they offer—for example, in parsing strings th.. 2023. 3. 23.
The Prototype Pattern The Builder Pattern We have already seen that the Factory pattern returns one of several different subclasses, depending on the data passed in arguments to the creation methods. But suppose we don’t want just a computing algorithm, but a whole different user interface depending on the data we need to display. A typical example might be your email address book. You probably have both people and g.. 2023. 3. 23.
The Singleton Pattern The Singleton pattern is grouped with the other creational patterns, although, to some extent, it is a “noncreational” pattern. 프로그래밍에는 클래스의 인스턴스가 하나만 있는지 확인해야 하는 경우가 많이 있습니다. For example, your system can have only one window manager or print spooler, as well as a single point of access to a database engine. Python does not directly have a feature where a single static variable will be accessibl.. 2023. 3. 23.
The Abstract Factory Pattern The Abstract Factory pattern is one level of abstraction higher than the Factory pattern. You use this pattern when you want to return one of several related classes of objects, each of which can return several different objects on request. In other words, the Abstract Factory is a factory object that returns one of several groups of classes. Determining which class from that group to use might .. 2023. 3. 23.
The Factory Method Pattern 5 장에서 우리는 가장 단순한 공장의 몇 가지 예를 보았습니다. 팩토리 개념은 객체 지향 프로그래밍 전체에서 반복됩니다. 이러한 경우 단일 클래스는 교통 경찰 역할을 하며 인스턴스화할 단일 계층의 하위 클래스를 결정합니다. Factory Method 패턴은 Factory pattern의 확장으로, 단일 클래스가 인스턴스화할 하위 클래스를 결정하지 않습니다. 대신 슈퍼클래스는 각 서브클래스에 대한 결정을 연기합니다. 이 패턴에는 실제로 하나의 하위 클래스가 다른 클래스보다 직접 선택되는 결정 지점이 없습니다. 대신 이 패턴으로 작성된 프로그램은 객체를 생성하지만 각 하위 클래스가 생성할 객체를 결정하도록 하는 추상 클래스를 정의합니다. straight seeding 1) Heat 배정 방식 - 기록 오름 .. 2023. 3. 23.
The Factory Pattern Creational Patterns All creational patterns deal with ways to create instances of objects. This is important because your program should not depend on how objects are created and arranged. In Python, of course, the simplest way to create an instance of an object is by creating a variable of that class type. fred = Fred()# instance of Fred class However, this really amounts to hard coding, depend.. 2023. 3. 23.