0% found this document useful (0 votes)
10 views

What are design patterns

Design patterns are defined as solutions to recurring problems within specific contexts, balancing goals and constraints. They can be categorized into three main types: Creational, Behavioral, and Structural, and are documented in pattern catalogs for better understanding and application. The concept originated from architecture and has been adapted for software development, with anti-patterns highlighting common bad solutions to avoid.

Uploaded by

ppngodidi322
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

What are design patterns

Design patterns are defined as solutions to recurring problems within specific contexts, balancing goals and constraints. They can be categorized into three main types: Creational, Behavioral, and Structural, and are documented in pattern catalogs for better understanding and application. The concept originated from architecture and has been adapted for software development, with anti-patterns highlighting common bad solutions to avoid.

Uploaded by

ppngodidi322
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

What are design patterns?

Design Pattern Defined


So what exactly is a design pattern?

A pattern is a solution to a problem in context.

Problem: The goal you are trying to achieve in this context.


Context: Situation in which the pattern applies.
Solution: what you’re after: a general design that anyone can
apply which resolves the goal and set of constraints.
Design Pattern Defined
So what exactly is a design pattern?

A pattern is a solution to a problem in context.

Problem: How do I get to work on time?


Context: I’ve locked my keys in the car.
Solution: Break the window, get in the car, start the engine and
drive to work.
Design Pattern Defined
So what exactly is a design pattern?

A pattern is a solution to a problem in context.

Problem: You need to step through the objects without


exposing the collection’s implementation.
Context: A collection of objects.
Solution: Encapsulate the iteration into a separate class.
May the Force be with you
 The Design Pattern definition tells us that the problem consists
of a goal and a set of constraints.
 Patterns gurus have a term for these: they call them
forces….as in

If you remember the movie, the force “shapes and controls the Universe.”
Only when a solution balances both sides of the force (the light side: your goal, and the
dark side: the constraints) do we have a useful pattern.
Scrutinizing the definition
 The car key example does seem to match the Design Pattern
definition, but it isn’t a true pattern.

Why?
Scrutinizing the definition
 Because a pattern needs to apply to a recurring
problem.
 We need to be able to give it to someone so they
can apply it to their unique situation.
 It doesn’t have a name!
Scrutinizing the definition

Luckily, patterns are not described and


documented
as a simple problem, context and solution; we
have much better ways of describing patterns
and
collecting them together into patterns catalogs.
Patterns Catalogs
What is a pattern catalog?

A pattern catalog takes a set of patterns and describes each in


detail along with its relationship to the other patterns.
Patterns Catalogs
Patterns Catalogs
Patterns Catalogs
Classification
 In most catalogs you’ll find patterns grouped into one of a few
classification schemes.
 The most well-known scheme was used by the first pattern
catalog and partitions patterns into three distinct categories
based on their purposes:
• Creational
• Behavioural
• Structural
Classification
Classification
Patterns are often classified by a second attribute: whether
or not the pattern deals with classes or objects:
The Gang of Four
“the GoF,” which includes Erich Gamma, Richard
Helm, Ralph Johnson and John Vlissides, is the group of guys
who
put together the first patterns catalog and in the process,
started an
entire movement in the software field!
Origins
 Patterns didn’t start with the GoF; they started with Christopher
Alexander, a Professor of Architecture at Berkeley – that’s right,

Alexander is an architect , not a computer scientist.


Alexander invented patterns for building living architectures
(like houses, towns and cities).
Origins
 Patterns didn’t start with software; they started with the
architecture of buildings and towns.
 In fact, the patterns concept can be applied in many
different domains.
Some thoughts on patterns
• You need to be committed to be a patterns writer: it takes time and patience,
and you have to be willing to do lots of refinement.
• Most patterns you encounter will be adaptations of existing patterns, not new
patterns.
• Build your team’s shared vocabulary. This is one of the most powerful benefits
of using patterns.
When do we use them?

The Beginner uses patterns everywhere.

As learning progresses, the Intermediate mind starts
to see where patterns are needed and where they aren’t.

The Zen mind is able to see patterns where they fit naturally.
Anti-Patterns
 An Anti-Pattern tells you how to go from a problem to a
BAD solution.

Why?!
If there is a recurring bad solution to a common problem,
then by documenting it we can prevent other developers
from making the same mistake.
Anti-Patterns
Elements of an anti-pattern
 An anti-pattern tells you why a bad solution is attractive.
 An anti-pattern tells you why that solution in the long term is
bad.
 An anti-pattern suggests other patterns that are applicable
which may provide good solutions.
List of Design Patterns
 Strategy Pattern
 Observer Pattern
 Decorator Pattern
 Factory Method
 Abstract Factory Pattern
 Singleton Pattern
 Command Pattern
 Adapter Pattern
 Facade Pattern
 Template Method Pattern

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy