SlideShare a Scribd company logo
Design Patterns
Khaled kamara
1. Software crisis
2. How to be a better developer
3. Solving A problem
4. What and why Design patterns
5. Let’s code a game together
6. What else
7. How can you select the right design pattern
8. Some useful Design patterns for Graduation project
9. Architectural Pattern
10.Snap on software Architecture
Table of Content
Software crisis
Most software projects
fail completely or
partially because they
don’t meet all their
requirements. These
requirements can be
the cost, schedule,
quality, or
requirements
objectives. According
to many studies, the
failure rate of software
projects ranges
between 50% – 80%.
Data structure
Software engineering
Design Principles & Solid
Modern Architecture
Clean Code & Code Complexity
Best Practice&Generics
Design patterns
Patterns is
everywhere
Let’s make the Balloon Float
What is Design patterns
A standard solution to a common software problem in a
context.
▪ describes a recurring software structure or idiom
▪ is abstract from any particular programming language
▪ identifies classes and their roles in the solution to a problem
Same problem Different implementation
Benefits of using Design patterns
• Patterns give a design common vocabulary for software
design:
▪ Allows engineers to abstract a problem and talk about that
abstraction in isolation from its implementation.
▪ A culture; domain-specific patterns increase design speed.
• Capture expertise and allow it to be communicated:
▪ Promotes design reuse and avoid mistakes.
▪ Makes it easier for other developers to understand a system.
• Improve documentation (less is needed):
▪ Improve understandability (patterns are described well, once).
The change is the only fact
GOF
• in 1990 a group called the
Gang of Four or "GoF"
(Gamma, Helm, Johnson,
Vlissides) compile a
catalog of design patterns
o 1995 book Design Patterns:
Elements of Reusable
Object-Oriented
Software is a classic of the
field
Singleton
• intent: Ensure a class has only
one instance and provide a
global point of access to it
• Problem: How can we
guarantee that one and only
one instance of a class can be
created
• Solution
Types of Design patterns .
Creational
Simple Factory,Factory Method,Abstract
Factory,Builder,Prototype,Singleton
Behavioral
Chain of Responsibility,Command,Iterator,Mediator,
Memento,Observer,Visitor,Strategy,State, Template
Method
Structure
Adapter,Bridge,Composite,Decorator,Facade,
Flyweight,Proxy
Let’s Develop a game
Game Story
A game of a fighter walking in Road, facing random
enemies, Finding New Weapons and health potions.You
can choose different culture (pharos, bableons, Grease).
In case Fighter got spelled, it will affect his speed Very
slow or very fast.
Fighter has one check point in the middle of every level to
save his state, to return any time he want.
Every level up upgrade age(Stone age, Iron Age).
1. fighter
2. Enemies
3. culture
4. Potions
5. Level up
6. restart level
7. Checkpoint
8. Spells
9. New ages
Key Words
To create fighter you
need to go throw the
fighter wizard in which
you can choose Fighter
gender and type.
every user has 1000 Coin
you can purchase weapon
and armor that affect
can increase health or
strength
fighter
Builder
Intent
construct complex objects step by step. Also allows you to
produce different types and representations of an object using
the same construction code.
Problem
step-by-step initialization of many fields and nested objects.
Such initialization code is usually buried inside a monstrous
constructor with lots of parameters. Or even worse: scattered all
over the client code.
Solution:
Builder
We have many enemies in
the game with different
types and power.
Each level can has certain
number of each enemy
Enemies
Factory
Intent
Creating complex object by the simplest way,encapsulate whats vary
or adding logic to creation.
Problem
Creating the object is different or expensive, repetitive code,
Solution:
Factory
We have many culture
supported,
Culture is a theme for
the fighter ,enemies,
weapons, armos, flags
and colors
Culture
Bridge
Intent
split a large class or a set of
closely related classes into two
separate hierarchies—abstraction
and implementation—which can be
developed independently of each
other.
Problem
Merging classes can be messy
Solution:
Bridge
Fighter can find Potions
that improve his strength
or Armor
Potions
Decorator
Intent
Decorator is a structural design pattern that lets you attach new
behaviors to objects by placing these objects inside special wrapper
objects that contain the behaviors.
Problem
Imagine that you’re working on a notification library which lets other
programs notify their users about important events.
Solution:
Decorator
To restart level or to
create new level we have
many steps,
Like creating new
enemies, loading Page
celebrate if new level ,
say ooh if restart level
...etc
Level Up
facade
Intent
provides a simplified interface to a library, a framework, or any
other complex set of classes,User does not need to know all our
steps, just want my app to work
Problem
Functions can vary,can be from different source
Solution:
facade
The Game has many check
point, when the user
reach it he can save the
state ,in case he lost his
live or close the game he
can come back to this
point
Save CheckPoint
Memento
Also known as: Snapshot
Intent
save and restore the previous state of an object without revealing
the details of its implementation.
Problem
Want to come Back to the old State,simplest way.
Solution:
Memento
Enemies can cast
Spells on our fighter,
that can affect
fighter speed
Spells
State
Intent
lets an object alter its behavior when its internal state changes. It
appears as if the object changed its class.
Problem
The main idea is that, at any given moment, there’s a finite number
of states which a program can be in. Within any unique state, the
program behaves differently, and the program can be switched from
one state to another instantaneously.
Solution:
State
Every Level Introduce a
new Age, Every Age Steps
work in a different way to
create a unique Game
Board ,Enemies ,weapons,
armors and potions
Introduce New Age
Template
Intent
defines the skeleton of an algorithm in the superclass but lets
subclasses override specific steps of the algorithm without changing
its structure.
Problem
To handle the code in a different way, system will need to create a
lot of classes that will be redundant
Solution:
Template
Do not overuse the patterns
Overusing the patterns,can
Complicate our Code.
One million dollar Pen
In the cold war between america
and russia there was a space war,
astronauts needed pens to write,
american scientist invented a pen
that cost million dollar.
While russian write in pencil
CarGo Cult Programming
1. Identify the problem
2. Review the existing patterns
3. Evaluate the pros and cons
4. Apply the pattern
How can you select the right design pattern for your project?
We can use part of design
pattern to solve the problem or
combine between them.
Are there more design
patterns than the 23 of
Gang oF four?
• The fact that GoF realized the power of the pattern language,
and wrote the first book does not limit the patterns to the 23.
• patterns is a very rich subject and not limitative to any list
provided by any single individual.
Are there more design patterns than the 23 of Gang oF four?
• There are plenty of other pattern repositories. As example,
there are Martin Fowler’s (more than 50) patterns of
enterprise application architecture, which are -despite their
name- also design patterns.
• There are several other repositories and books that describe
either general patterns or domain specific patterns, like for
example for the gaming industry.
● You can try to invent one yourself as an
academic exercise, but as this answer already
suggests, the best way to uncover these
patterns is to find a bunch of seemingly
unrelated problems that have a common
solution. That common solution becomes the
design pattern.
How do we find new patterns?
● For example, the (Josh Bloch builder pattern (not to be
confused with the Gang of Four's builder pattern)) arose out
of the need for a readable way to initialize an object with a
large number of parameters, and was heavily influenced by
another design pattern, the fluent interface/API.
1. MVC
2. Generic /regular Repository
3. Unit of work
4. Dependency Injection Pattern
5. Circuit Breaker
6. Command and Query Responsibility Segregation (CQRS)
7. Event Sourcing
8. Sidecar
9. Backend-for-Frontend
10. Strangler
Modern-Day Design Patterns
Some useful Design patterns for Graduation project
What is MVC
Model View Controller
Is it a pattern?
All architectural patterns are design patterns, but not all design
patterns are architectural. it's called architectural when its high
level pattern chosen in the application design phase.
MVC
An architectural pattern is a general, reusable solution to a
commonly occurring problem in software architecture within a
given context. Architectural patterns are similar to software
design pattern but have a broader scope.
Most Common
● MVC
● MVP
● MVVM
● CQRS
Architectural Pattern
Architecture
Vs
Architecture Pattern
VS
Design pattern
● Software as a service
● MicroServices
● Onion Architecture
● Clean Architecture
● N-Tire (Layered Architecture)
● Serverless Architecture
● Event-Driven Architecture (Event Sourcing)
● Domain Driven Design (DDD)
Some Software Architectural
Design
Principles
samples
Anti Patterns
● Anti-patterns are the opposite of best practice, which is a
solution that has been proven to be effective. They are often
used because they seem to work, but the larger context or
the long-term consequences are often not considered. They
can occur in :
● software design
● project management
● organizational behavior.
We should avoid Anti-Patterns
Anti-Patterns
common mistakes or poor practices when writing source code. That can lead
to problems like increased complexity and reduced maintainability.
● Spaghetti Code
● Boat anchor /Lava Flow
● Accidental Complexity
● God Object
● Hard Code / soft Code
● Magic (Numbers /Strings)
● Golden hammer
● Dead Code
● CarGo Cult Programming
● Single function exist point
Programming Anti-patterns
Anti Patterns (Cont.)

More Related Content

Similar to Design Patterns- Course for students .pptx

A Pragmatic Approach
A Pragmatic ApproachA Pragmatic Approach
A Pragmatic Approach
HakanCanpek
 
Design Patterns Course
Design Patterns CourseDesign Patterns Course
Design Patterns Course
Ahmed Soliman
 
Refactoring 2 The Max
Refactoring 2 The MaxRefactoring 2 The Max
Refactoring 2 The Max
Alfredo Morresi
 
010821+presentation+oti.ppt
010821+presentation+oti.ppt010821+presentation+oti.ppt
010821+presentation+oti.ppt
Yann-Gaël Guéhéneuc
 
L05 Design Patterns
L05 Design PatternsL05 Design Patterns
L05 Design Patterns
Ólafur Andri Ragnarsson
 
C programming interview questions
C programming interview questionsC programming interview questions
C programming interview questions
adarshynl
 
Refactoring, 2nd Edition
Refactoring, 2nd EditionRefactoring, 2nd Edition
Refactoring, 2nd Edition
jexp
 
Boost Your Base Bootcamp - [Online & Offline] In Bangla
Boost Your Base Bootcamp - [Online & Offline] In BanglaBoost Your Base Bootcamp - [Online & Offline] In Bangla
Boost Your Base Bootcamp - [Online & Offline] In Bangla
Stack Learner
 
Design pattern
Design patternDesign pattern
Design pattern
Shreyance Jain
 
Cprogramminginterviewquestions 120622074544-phpapp01
Cprogramminginterviewquestions 120622074544-phpapp01Cprogramminginterviewquestions 120622074544-phpapp01
Cprogramminginterviewquestions 120622074544-phpapp01
chandu_microcosm
 
The I in PRIMM - Code Comprehension and Questioning
The I in PRIMM - Code Comprehension and QuestioningThe I in PRIMM - Code Comprehension and Questioning
The I in PRIMM - Code Comprehension and Questioning
Sue Sentance
 
Continuous Deployment and Testing Workshop from Better Software West
Continuous Deployment and Testing Workshop from Better Software WestContinuous Deployment and Testing Workshop from Better Software West
Continuous Deployment and Testing Workshop from Better Software West
Cory Foy
 
C# Interview Questions | Edureka
C# Interview Questions | EdurekaC# Interview Questions | Edureka
C# Interview Questions | Edureka
Edureka!
 
Contemporary Software Engineering Practices Together With Enterprise
Contemporary Software Engineering Practices Together With EnterpriseContemporary Software Engineering Practices Together With Enterprise
Contemporary Software Engineering Practices Together With EnterpriseKenan Sevindik
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design Principles
Steve Zhang
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - Implementation
Blue Elephant Consulting
 
OOP Java
OOP JavaOOP Java
OOP Java
Saif Kassim
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting Started
Martin Chapman
 
Create first android app with MVVM Architecture
Create first android app with MVVM ArchitectureCreate first android app with MVVM Architecture
Create first android app with MVVM Architecture
khushbu thakker
 
12266422.ppt
12266422.ppt12266422.ppt
12266422.ppt
CSEC5
 

Similar to Design Patterns- Course for students .pptx (20)

A Pragmatic Approach
A Pragmatic ApproachA Pragmatic Approach
A Pragmatic Approach
 
Design Patterns Course
Design Patterns CourseDesign Patterns Course
Design Patterns Course
 
Refactoring 2 The Max
Refactoring 2 The MaxRefactoring 2 The Max
Refactoring 2 The Max
 
010821+presentation+oti.ppt
010821+presentation+oti.ppt010821+presentation+oti.ppt
010821+presentation+oti.ppt
 
L05 Design Patterns
L05 Design PatternsL05 Design Patterns
L05 Design Patterns
 
C programming interview questions
C programming interview questionsC programming interview questions
C programming interview questions
 
Refactoring, 2nd Edition
Refactoring, 2nd EditionRefactoring, 2nd Edition
Refactoring, 2nd Edition
 
Boost Your Base Bootcamp - [Online & Offline] In Bangla
Boost Your Base Bootcamp - [Online & Offline] In BanglaBoost Your Base Bootcamp - [Online & Offline] In Bangla
Boost Your Base Bootcamp - [Online & Offline] In Bangla
 
Design pattern
Design patternDesign pattern
Design pattern
 
Cprogramminginterviewquestions 120622074544-phpapp01
Cprogramminginterviewquestions 120622074544-phpapp01Cprogramminginterviewquestions 120622074544-phpapp01
Cprogramminginterviewquestions 120622074544-phpapp01
 
The I in PRIMM - Code Comprehension and Questioning
The I in PRIMM - Code Comprehension and QuestioningThe I in PRIMM - Code Comprehension and Questioning
The I in PRIMM - Code Comprehension and Questioning
 
Continuous Deployment and Testing Workshop from Better Software West
Continuous Deployment and Testing Workshop from Better Software WestContinuous Deployment and Testing Workshop from Better Software West
Continuous Deployment and Testing Workshop from Better Software West
 
C# Interview Questions | Edureka
C# Interview Questions | EdurekaC# Interview Questions | Edureka
C# Interview Questions | Edureka
 
Contemporary Software Engineering Practices Together With Enterprise
Contemporary Software Engineering Practices Together With EnterpriseContemporary Software Engineering Practices Together With Enterprise
Contemporary Software Engineering Practices Together With Enterprise
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design Principles
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - Implementation
 
OOP Java
OOP JavaOOP Java
OOP Java
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting Started
 
Create first android app with MVVM Architecture
Create first android app with MVVM ArchitectureCreate first android app with MVVM Architecture
Create first android app with MVVM Architecture
 
12266422.ppt
12266422.ppt12266422.ppt
12266422.ppt
 

Recently uploaded

Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
Sharepoint Designs
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
NaapbooksPrivateLimi
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 

Recently uploaded (20)

Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024Explore Modern SharePoint Templates for 2024
Explore Modern SharePoint Templates for 2024
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 

Design Patterns- Course for students .pptx

  • 2. 1. Software crisis 2. How to be a better developer 3. Solving A problem 4. What and why Design patterns 5. Let’s code a game together 6. What else 7. How can you select the right design pattern 8. Some useful Design patterns for Graduation project 9. Architectural Pattern 10.Snap on software Architecture Table of Content
  • 3. Software crisis Most software projects fail completely or partially because they don’t meet all their requirements. These requirements can be the cost, schedule, quality, or requirements objectives. According to many studies, the failure rate of software projects ranges between 50% – 80%.
  • 4.
  • 5. Data structure Software engineering Design Principles & Solid Modern Architecture Clean Code & Code Complexity Best Practice&Generics Design patterns
  • 7. Let’s make the Balloon Float
  • 8.
  • 9. What is Design patterns A standard solution to a common software problem in a context. ▪ describes a recurring software structure or idiom ▪ is abstract from any particular programming language ▪ identifies classes and their roles in the solution to a problem Same problem Different implementation
  • 10. Benefits of using Design patterns • Patterns give a design common vocabulary for software design: ▪ Allows engineers to abstract a problem and talk about that abstraction in isolation from its implementation. ▪ A culture; domain-specific patterns increase design speed. • Capture expertise and allow it to be communicated: ▪ Promotes design reuse and avoid mistakes. ▪ Makes it easier for other developers to understand a system. • Improve documentation (less is needed): ▪ Improve understandability (patterns are described well, once). The change is the only fact
  • 11. GOF • in 1990 a group called the Gang of Four or "GoF" (Gamma, Helm, Johnson, Vlissides) compile a catalog of design patterns o 1995 book Design Patterns: Elements of Reusable Object-Oriented Software is a classic of the field
  • 12.
  • 13. Singleton • intent: Ensure a class has only one instance and provide a global point of access to it • Problem: How can we guarantee that one and only one instance of a class can be created • Solution
  • 14. Types of Design patterns . Creational Simple Factory,Factory Method,Abstract Factory,Builder,Prototype,Singleton Behavioral Chain of Responsibility,Command,Iterator,Mediator, Memento,Observer,Visitor,Strategy,State, Template Method Structure Adapter,Bridge,Composite,Decorator,Facade, Flyweight,Proxy
  • 16. Game Story A game of a fighter walking in Road, facing random enemies, Finding New Weapons and health potions.You can choose different culture (pharos, bableons, Grease). In case Fighter got spelled, it will affect his speed Very slow or very fast. Fighter has one check point in the middle of every level to save his state, to return any time he want. Every level up upgrade age(Stone age, Iron Age).
  • 17. 1. fighter 2. Enemies 3. culture 4. Potions 5. Level up 6. restart level 7. Checkpoint 8. Spells 9. New ages Key Words
  • 18. To create fighter you need to go throw the fighter wizard in which you can choose Fighter gender and type. every user has 1000 Coin you can purchase weapon and armor that affect can increase health or strength fighter
  • 20. Intent construct complex objects step by step. Also allows you to produce different types and representations of an object using the same construction code. Problem step-by-step initialization of many fields and nested objects. Such initialization code is usually buried inside a monstrous constructor with lots of parameters. Or even worse: scattered all over the client code. Solution: Builder
  • 21. We have many enemies in the game with different types and power. Each level can has certain number of each enemy Enemies
  • 23. Intent Creating complex object by the simplest way,encapsulate whats vary or adding logic to creation. Problem Creating the object is different or expensive, repetitive code, Solution: Factory
  • 24. We have many culture supported, Culture is a theme for the fighter ,enemies, weapons, armos, flags and colors Culture
  • 26. Intent split a large class or a set of closely related classes into two separate hierarchies—abstraction and implementation—which can be developed independently of each other. Problem Merging classes can be messy Solution: Bridge
  • 27. Fighter can find Potions that improve his strength or Armor Potions
  • 29. Intent Decorator is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors. Problem Imagine that you’re working on a notification library which lets other programs notify their users about important events. Solution: Decorator
  • 30. To restart level or to create new level we have many steps, Like creating new enemies, loading Page celebrate if new level , say ooh if restart level ...etc Level Up
  • 32. Intent provides a simplified interface to a library, a framework, or any other complex set of classes,User does not need to know all our steps, just want my app to work Problem Functions can vary,can be from different source Solution: facade
  • 33. The Game has many check point, when the user reach it he can save the state ,in case he lost his live or close the game he can come back to this point Save CheckPoint
  • 35. Also known as: Snapshot Intent save and restore the previous state of an object without revealing the details of its implementation. Problem Want to come Back to the old State,simplest way. Solution: Memento
  • 36. Enemies can cast Spells on our fighter, that can affect fighter speed Spells
  • 37. State
  • 38. Intent lets an object alter its behavior when its internal state changes. It appears as if the object changed its class. Problem The main idea is that, at any given moment, there’s a finite number of states which a program can be in. Within any unique state, the program behaves differently, and the program can be switched from one state to another instantaneously. Solution: State
  • 39. Every Level Introduce a new Age, Every Age Steps work in a different way to create a unique Game Board ,Enemies ,weapons, armors and potions Introduce New Age
  • 41. Intent defines the skeleton of an algorithm in the superclass but lets subclasses override specific steps of the algorithm without changing its structure. Problem To handle the code in a different way, system will need to create a lot of classes that will be redundant Solution: Template
  • 42. Do not overuse the patterns Overusing the patterns,can Complicate our Code. One million dollar Pen In the cold war between america and russia there was a space war, astronauts needed pens to write, american scientist invented a pen that cost million dollar. While russian write in pencil CarGo Cult Programming
  • 43. 1. Identify the problem 2. Review the existing patterns 3. Evaluate the pros and cons 4. Apply the pattern How can you select the right design pattern for your project? We can use part of design pattern to solve the problem or combine between them.
  • 44. Are there more design patterns than the 23 of Gang oF four?
  • 45. • The fact that GoF realized the power of the pattern language, and wrote the first book does not limit the patterns to the 23. • patterns is a very rich subject and not limitative to any list provided by any single individual. Are there more design patterns than the 23 of Gang oF four?
  • 46. • There are plenty of other pattern repositories. As example, there are Martin Fowler’s (more than 50) patterns of enterprise application architecture, which are -despite their name- also design patterns. • There are several other repositories and books that describe either general patterns or domain specific patterns, like for example for the gaming industry.
  • 47. ● You can try to invent one yourself as an academic exercise, but as this answer already suggests, the best way to uncover these patterns is to find a bunch of seemingly unrelated problems that have a common solution. That common solution becomes the design pattern. How do we find new patterns? ● For example, the (Josh Bloch builder pattern (not to be confused with the Gang of Four's builder pattern)) arose out of the need for a readable way to initialize an object with a large number of parameters, and was heavily influenced by another design pattern, the fluent interface/API.
  • 48. 1. MVC 2. Generic /regular Repository 3. Unit of work 4. Dependency Injection Pattern 5. Circuit Breaker 6. Command and Query Responsibility Segregation (CQRS) 7. Event Sourcing 8. Sidecar 9. Backend-for-Frontend 10. Strangler Modern-Day Design Patterns Some useful Design patterns for Graduation project
  • 49. What is MVC Model View Controller Is it a pattern? All architectural patterns are design patterns, but not all design patterns are architectural. it's called architectural when its high level pattern chosen in the application design phase. MVC
  • 50. An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context. Architectural patterns are similar to software design pattern but have a broader scope. Most Common ● MVC ● MVP ● MVVM ● CQRS Architectural Pattern
  • 52. ● Software as a service ● MicroServices ● Onion Architecture ● Clean Architecture ● N-Tire (Layered Architecture) ● Serverless Architecture ● Event-Driven Architecture (Event Sourcing) ● Domain Driven Design (DDD) Some Software Architectural
  • 55. ● Anti-patterns are the opposite of best practice, which is a solution that has been proven to be effective. They are often used because they seem to work, but the larger context or the long-term consequences are often not considered. They can occur in : ● software design ● project management ● organizational behavior. We should avoid Anti-Patterns Anti-Patterns
  • 56. common mistakes or poor practices when writing source code. That can lead to problems like increased complexity and reduced maintainability. ● Spaghetti Code ● Boat anchor /Lava Flow ● Accidental Complexity ● God Object ● Hard Code / soft Code ● Magic (Numbers /Strings) ● Golden hammer ● Dead Code ● CarGo Cult Programming ● Single function exist point Programming Anti-patterns