Design Patterns 1 Flashcards
(46 cards)
a reusable solution to a
common problem that occurs in a given
context within software design.
design pattern
- It captures best practices and proven strategies
from experienced developers and architects. - Inspired by architectural patterns in mature
engineering fields (e.g., civil, automotive).
design pattern
Why Use Design Patterns?
EHER
- Encourage reuse of design structures rather than
writing code from scratch. - Help in creating systems that are scalable,
flexible, and maintainable. - Establish a common vocabulary for developers
(e.g., “Use a Singleton here”). - Reduce design errors by reusing well-tested
solutions.
- Introduced by Gamma, Helm, Johnson, and
Vlissides in their 1995 book “Design Patterns:
Elements of Reusable Object-Oriented
Software.” - Cataloged 23 patterns classified into three
categories: Creational, Structural, and
Behavioral.
The “Gang of Four” (GoF) Design Patterns
Gang of Four Design Patterns was introduced by
Gamma, Helm, Johnson, and Vlissides in their 1995 book “Design Patterns: Elements of Reusable Object-Oriented Software.”
The “Gang of Four” (GoF) Design Patterns Cataloged 23 patterns classified into three
CSB
Creational,
Structural, and
Behavioral.
Essential Elements of a Design Pattern
Pattern Name
Problem
Solution
Consequences
Unique identifier to facilitate communication (essential elements of design pattern)
Pattern Name
Describes the scenario where the pattern applies (essential elements of design pattern)
Problem
Abstract design, note code, often expressed in UML (essential elements of design pattern)
Solution
Results and trade-offs of applying the pattern (essential elements of design pattern)
Consequences
Types of Design Patterns
CSB
- Creational patterns
- Structural patterns
- Behavioral patterns
Focus on object creation mechanisms, trying
to create objects in a manner suitable to the
situation.
Creational Patterns
Creational Patterns Examples
SFABP
Singleton
Factory Method
Abstract Factory
Builder
Prototype
Ensure only one instance of a class exist (CP)
Singleton
Let subclasses decide which class to instantiate (CP)
Factory method
Interface for creating families of related objects (CP)
Abstract Factory
Construct complex objects step-by-step (CP)
Builder
Clone an object to create a new one (CP)
Prototype
Concerned with composing classes and
objects to form larger structures.
Structural Patterns
Structural Patterns Examples
ABCDFFP
Adapter
Bridge
Composite
Decorator
Facade
Flyweight
Proxy
Converts one interface into another (SP)
Adapter
Separates abstraction from implementation. (SP)
Bridge
Treats individual objects and compositions uniformly (SP)
Composite