SlideShare a Scribd company logo
1 of 24
Download to read offline
Lecture # 2
        Ahmed Safwat
Abdelrahman Z. Al-Ogail
     Muhamad Hesham
   Call for a new requirement.
   First try for implementation.
   Bad smell code.
   Meet observer pattern.
   Pattern class diagram.
   Second try for implementation.(developing
    pattern in C#).
   Common uses.
   What’s next? (Further reading).
Call for new requirement


    Once the player collects a
     gem I want:
      Enemy increases its speed.
      Other gems change its color
      to a random color.
First try for implementation



1. We need find the place in code where
the gem is tested for being collected.

2. We need modify enemy speed.
3. We need modify gem color.
Our code smells bad!


   What bad things we did ?
    1. We expose private
     members to the public.

    2. We are dependant on
     certain members.

    3. Each time we need modify
     the level code.
Real life example




Do you know how news paper
     subscribtion work ?
Publisher + Subscriber




Publisher




   Not notified
                                           Subscribers
Publisher + Subscriber




Publisher




                Subscribe



                                     Subscribers
Publisher + Subscriber




Publisher




                                     Subscribers
Publisher + Subscriber




                                         I am not
Publisher                               interested
                                         anymore




                                     Subscribers
Publisher + Subscriber




Publisher




   Not notified
                                           Subscribers
Discovering Pattern   Let’s Google it!
Explaining the Pattern   See how it’s easy!
Class Diagram   Source: GoF’s Book
Implementation    Developing the pattern in C#


     See how we develop a pattern!
Call for new requirement


    Once the player die I want:
      Enemies speed is reset.
      Other gems change its color
      to black.
Just pattern it



1. We need find the place in code where
the gem is player is tested for being dead.

2. We need reset enemy speed.
3. We need modify color gem with
black.
Common Uses        Source: GoF’s Book


    Spreadsheets, Bar Graph and Pie Graph
     presentations of the same data.
    Chat Windows in IMs.
    RSS and News-feed.
    In Smalltalk programming language MVC
      Model: subject
      View: observers
What’s Next?              Wait a minute! What about the rest


     Patterns explanation in GoF
       Pattern Name and Classification: A descriptive and unique name that
        helps in identifying and referring to the pattern
       Intent: A description of the goal behind the pattern and the reason for
        using it.
       Also Known As: Other names for the pattern
       Motivation (Forces): A scenario consisting of a problem and a context
        in which this pattern can be used.
What’s Next?              Wait a minute! What about the rest


     Patterns explanation in GoF
       Consequences: A description of the results, side effects, and trade offs
        caused by using the pattern.
       Sample Code: An illustration of how the pattern can be used in a
        programming language
       Known Uses: Examples of real usages of the pattern.
       Related Patterns: Other patterns that have some relationship with the
        pattern; discussion of the differences between the pattern and similar
        patterns
What’s Next?          Not Covered points


     Design Advantages of using this pattern:
       Objects are loosely coupled.
       Adding new observers at any time without effort.
       Changes in subject or observer don’t effect the other
It is about times


   How they attended Lessons?
   How they managed their time?
     Reading while eating & walking
     Eating Ka`ak
   Results:
     Bagdad Library
     Saheb Abn Abbad`s Library
      ▪ Lon Gorand talking about his books 400 Hajri.
What’s Next       Books to read


     Head First – Design Patterns: Chapter # 2
     GoF – Behavioral Patterns Section
Questions??
ahmedaliyousif@acm.org
Mhesham.fcis@gmail.com
 Zikas_zak@hotmail.com

More Related Content

Similar to Design Patterns Summer Course 2009-2010 - Session#2

Turning Passion Into Words
Turning Passion Into WordsTurning Passion Into Words
Turning Passion Into Words
Brian Hogan
 
Scottish Ruby Conference 2014
Scottish Ruby Conference  2014Scottish Ruby Conference  2014
Scottish Ruby Conference 2014
michaelag1971
 
Good code, Bad Code
Good code, Bad CodeGood code, Bad Code
Good code, Bad Code
josedasilva
 
Everyone hacks design at a hackathon
Everyone hacks   design at a hackathonEveryone hacks   design at a hackathon
Everyone hacks design at a hackathon
Willow Brugh
 
Ruby object model
Ruby object modelRuby object model
Ruby object model
mbeizer
 

Similar to Design Patterns Summer Course 2009-2010 - Session#2 (20)

Make a better with clean code
Make a better with clean codeMake a better with clean code
Make a better with clean code
 
Turning Passion Into Words
Turning Passion Into WordsTurning Passion Into Words
Turning Passion Into Words
 
Pair writing: how to collaborate effectively with subject matter experts – Co...
Pair writing: how to collaborate effectively with subject matter experts – Co...Pair writing: how to collaborate effectively with subject matter experts – Co...
Pair writing: how to collaborate effectively with subject matter experts – Co...
 
Scottish Ruby Conference 2014
Scottish Ruby Conference  2014Scottish Ruby Conference  2014
Scottish Ruby Conference 2014
 
Game design 2 (2013): Lecture 14 - Revision
Game design 2 (2013): Lecture 14 - RevisionGame design 2 (2013): Lecture 14 - Revision
Game design 2 (2013): Lecture 14 - Revision
 
Comment soup with a pinch of types
Comment soup with a pinch of typesComment soup with a pinch of types
Comment soup with a pinch of types
 
DrupalMAD 2011-04
DrupalMAD 2011-04DrupalMAD 2011-04
DrupalMAD 2011-04
 
What would your own version of Ruby look like? (RubyKaigi)
What would your own version of Ruby look like? (RubyKaigi)What would your own version of Ruby look like? (RubyKaigi)
What would your own version of Ruby look like? (RubyKaigi)
 
Comment soup with a pinch of types, served in a leaky bowl
Comment soup with a pinch of types, served in a leaky bowlComment soup with a pinch of types, served in a leaky bowl
Comment soup with a pinch of types, served in a leaky bowl
 
Good code, Bad Code
Good code, Bad CodeGood code, Bad Code
Good code, Bad Code
 
Advanced java script essentials v1
Advanced java script essentials v1Advanced java script essentials v1
Advanced java script essentials v1
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
What would your own version of Ruby look like?
What would your own version of Ruby look like?What would your own version of Ruby look like?
What would your own version of Ruby look like?
 
Lessons from the Trenches of Learning Game Design
Lessons from the Trenches of Learning Game DesignLessons from the Trenches of Learning Game Design
Lessons from the Trenches of Learning Game Design
 
Fitc Amsterdam 2010
Fitc Amsterdam 2010Fitc Amsterdam 2010
Fitc Amsterdam 2010
 
Everyone hacks design at a hackathon
Everyone hacks   design at a hackathonEveryone hacks   design at a hackathon
Everyone hacks design at a hackathon
 
Global Day of Coderetreat 2013 Chennai - JUGChennai
Global Day of Coderetreat 2013 Chennai - JUGChennaiGlobal Day of Coderetreat 2013 Chennai - JUGChennai
Global Day of Coderetreat 2013 Chennai - JUGChennai
 
Ruby object model
Ruby object modelRuby object model
Ruby object model
 
Mob Programming for Continuous Learning
Mob Programming for Continuous LearningMob Programming for Continuous Learning
Mob Programming for Continuous Learning
 
Google summer of code
Google summer of codeGoogle summer of code
Google summer of code
 

More from Muhamad Hesham

Design Patterns Summer Course 2009-2010 - Session#4
Design Patterns Summer Course 2009-2010 - Session#4Design Patterns Summer Course 2009-2010 - Session#4
Design Patterns Summer Course 2009-2010 - Session#4
Muhamad Hesham
 
Design Patterns Summer Course 2009-2010 - Session#3
Design Patterns Summer Course 2009-2010 - Session#3Design Patterns Summer Course 2009-2010 - Session#3
Design Patterns Summer Course 2009-2010 - Session#3
Muhamad Hesham
 
Design Patterns Summer Course 2009-2010 - Session#1
Design Patterns Summer Course 2009-2010 - Session#1Design Patterns Summer Course 2009-2010 - Session#1
Design Patterns Summer Course 2009-2010 - Session#1
Muhamad Hesham
 
Design Patterns Summer Course 2010-2011 - Session#1
Design Patterns Summer Course 2010-2011 - Session#1Design Patterns Summer Course 2010-2011 - Session#1
Design Patterns Summer Course 2010-2011 - Session#1
Muhamad Hesham
 
1st Seminar- Intelligent Agent for Medium-Level Artificial Intelligence in Re...
1st Seminar- Intelligent Agent for Medium-Level Artificial Intelligence in Re...1st Seminar- Intelligent Agent for Medium-Level Artificial Intelligence in Re...
1st Seminar- Intelligent Agent for Medium-Level Artificial Intelligence in Re...
Muhamad Hesham
 

More from Muhamad Hesham (7)

NTP Software Jan 2012 Monthly Meeting IPC Presentation
NTP Software Jan 2012 Monthly Meeting IPC PresentationNTP Software Jan 2012 Monthly Meeting IPC Presentation
NTP Software Jan 2012 Monthly Meeting IPC Presentation
 
Design Patterns Summer Course 2009-2010 - Session#4
Design Patterns Summer Course 2009-2010 - Session#4Design Patterns Summer Course 2009-2010 - Session#4
Design Patterns Summer Course 2009-2010 - Session#4
 
Design Patterns Summer Course 2009-2010 - Session#3
Design Patterns Summer Course 2009-2010 - Session#3Design Patterns Summer Course 2009-2010 - Session#3
Design Patterns Summer Course 2009-2010 - Session#3
 
Design Patterns Summer Course 2009-2010 - Session#1
Design Patterns Summer Course 2009-2010 - Session#1Design Patterns Summer Course 2009-2010 - Session#1
Design Patterns Summer Course 2009-2010 - Session#1
 
Design Patterns Summer Course 2010-2011 - Session#1
Design Patterns Summer Course 2010-2011 - Session#1Design Patterns Summer Course 2010-2011 - Session#1
Design Patterns Summer Course 2010-2011 - Session#1
 
1st Seminar- Intelligent Agent for Medium-Level Artificial Intelligence in Re...
1st Seminar- Intelligent Agent for Medium-Level Artificial Intelligence in Re...1st Seminar- Intelligent Agent for Medium-Level Artificial Intelligence in Re...
1st Seminar- Intelligent Agent for Medium-Level Artificial Intelligence in Re...
 
[K Engine] Intorduction To Machine Planning, A Case Based Approach
[K Engine] Intorduction To Machine Planning, A Case Based Approach[K Engine] Intorduction To Machine Planning, A Case Based Approach
[K Engine] Intorduction To Machine Planning, A Case Based Approach
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Design Patterns Summer Course 2009-2010 - Session#2

  • 1. Lecture # 2 Ahmed Safwat Abdelrahman Z. Al-Ogail Muhamad Hesham
  • 2. Call for a new requirement.  First try for implementation.  Bad smell code.  Meet observer pattern.  Pattern class diagram.  Second try for implementation.(developing pattern in C#).  Common uses.  What’s next? (Further reading).
  • 3. Call for new requirement  Once the player collects a gem I want:  Enemy increases its speed.  Other gems change its color to a random color.
  • 4. First try for implementation 1. We need find the place in code where the gem is tested for being collected. 2. We need modify enemy speed. 3. We need modify gem color.
  • 5. Our code smells bad!  What bad things we did ? 1. We expose private members to the public. 2. We are dependant on certain members. 3. Each time we need modify the level code.
  • 6. Real life example Do you know how news paper subscribtion work ?
  • 7. Publisher + Subscriber Publisher Not notified Subscribers
  • 8. Publisher + Subscriber Publisher Subscribe Subscribers
  • 10. Publisher + Subscriber I am not Publisher interested anymore Subscribers
  • 11. Publisher + Subscriber Publisher Not notified Subscribers
  • 12. Discovering Pattern Let’s Google it!
  • 13. Explaining the Pattern See how it’s easy!
  • 14. Class Diagram Source: GoF’s Book
  • 15. Implementation Developing the pattern in C#  See how we develop a pattern!
  • 16. Call for new requirement  Once the player die I want:  Enemies speed is reset.  Other gems change its color to black.
  • 17. Just pattern it 1. We need find the place in code where the gem is player is tested for being dead. 2. We need reset enemy speed. 3. We need modify color gem with black.
  • 18. Common Uses Source: GoF’s Book  Spreadsheets, Bar Graph and Pie Graph presentations of the same data.  Chat Windows in IMs.  RSS and News-feed.  In Smalltalk programming language MVC  Model: subject  View: observers
  • 19. What’s Next? Wait a minute! What about the rest  Patterns explanation in GoF  Pattern Name and Classification: A descriptive and unique name that helps in identifying and referring to the pattern  Intent: A description of the goal behind the pattern and the reason for using it.  Also Known As: Other names for the pattern  Motivation (Forces): A scenario consisting of a problem and a context in which this pattern can be used.
  • 20. What’s Next? Wait a minute! What about the rest  Patterns explanation in GoF  Consequences: A description of the results, side effects, and trade offs caused by using the pattern.  Sample Code: An illustration of how the pattern can be used in a programming language  Known Uses: Examples of real usages of the pattern.  Related Patterns: Other patterns that have some relationship with the pattern; discussion of the differences between the pattern and similar patterns
  • 21. What’s Next? Not Covered points  Design Advantages of using this pattern:  Objects are loosely coupled.  Adding new observers at any time without effort.  Changes in subject or observer don’t effect the other
  • 22. It is about times  How they attended Lessons?  How they managed their time?  Reading while eating & walking  Eating Ka`ak  Results:  Bagdad Library  Saheb Abn Abbad`s Library ▪ Lon Gorand talking about his books 400 Hajri.
  • 23. What’s Next Books to read  Head First – Design Patterns: Chapter # 2  GoF – Behavioral Patterns Section