Design Patterns and Principles Chapter 2 Flashcards
____ _____ ____ in python focus on HOW objects are created and managed, ensuring flexibility, efficiency, and maintainability in your code.
They provide a structured approach to object instantiation, making it easier to control the creation process and decouple the creation logic from the rest of you application.
Creational Design Pattern
Creational Design Pattern(s) (SFABP)
Singleton
Factory Method
Abstract Factory
Builder
Prototype
One of the simplest design patterns: it involves only ONE CLASS which is responsible to MAKE SURE THERE IS NO MORE THAN ONE INSTANCE; it does it by instantiating itself and in the same time it provides a GLOBAL POINT OF ACCESS to that instance.
Singleton
Ensure that only one instance of a class is created and provide access point to the object
Singleton
The most used design pattern in modern programming languages like Java and C#. It comes in different variants and implementation
Factory Method
Defines an interface for creating objects, but let subclasses to decide which class to instantiate and Refers to the newly created object through a common interface.
Creates OBJ w/o exposing INST Logic to client
Ref to newly created OBJ thru COMMON INTERFACE
FACTORY MODE
A pattern that provides an interface for creating families of related or dependent object without specifying their concrete classes.
Abstract factory
To avoid adding code to existing classes and to support encapsulation, with this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this facotry is paired with any concrete factory to produce objects that follow the pattern of a certain country
A super-factory which creates other factories(Factory of factories)
Abstract FACTORY
Defines an instance of creating an object but letting subclasses decide which class to instantiate and allows a finer control over the construction process.
Defines an instance for creating an object but letting subclasses decide which class to instantiate
Refers to the newly created object through a common interface
Builder
allows an object to create customized objects without knowing their class or any details of how to create them.
Prototype
Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype
Lets you copy existing objects without making your code dependent on their classes
Useful when object creation is constly
Prototype
are a subset of design pattern in software development that focus on the composition of classes or objects to form a larger, more complex structures
Structural Design Pattern
Structural Design Patter(s)(ABCDFPF)
Adapter
Bridge
Composite
Decorator
Flyweight
Proxy
Facade
A structural design pattern, it allows you to make TWO INCOMPATIBLE interfaces WORK TOGETHER by creating a bridge between them
Use when you need to make incompatible interface work
Adapter
The intent of this pattern is to DECOUPLE ABSTRACTION from implementation so that the two can vary INDEPENDENTLY.
Use when you want to separate an abstraction from its implementation
Bridge