SlideShare a Scribd company logo
Agile Saturday VI




        Choose a pattern
         for a problem!


Anton Keks
anton@codeborne.com
The Increasing Complexity

Complexity of software systems
                                    Time

New programming paradigms
Higher level of abstraction
HW Assembler Structural   (objects+functions?)
  CPUs  Procedural    <OOP>                ...
What are design patterns?
●
    Anywhere in the world you can find recurring
    patterns
●   Design patterns
    –   are building blocks of a system's
        architecture
    –   are recurring solutions to design problems
        that you see over
    –   identify and specify abstractions that are
        above the level of single classes and
        instances
Pattern classification
The GOF book defines 3 major types of patterns:
–   Creational patterns – substitute the new keyword. This
    gives your program more flexibility in deciding which
    objects need to be created for a given case
–   Structural patterns - compose groups of objects into
    larger structures, such as complex user interfaces or
    accounting data
–   Behavioral patterns - define the communication
    between objects and how the flow is controlled in a
    complex program.
Decorator
Adapter
 Composite      Strategy
                 State
                   Observer
     Factory
                Iterator
  Builder
    Prototype
Software Design: The Good
●
    Loose coupling
●
    Immutability
●
    Encapsulation
●   Short code blocks
●   Appropriate typing
●
    Duplication avoidance
●   Simplicity
●
    Consistent terminology
●   Clear naming
Bad, bad, bad!
●
    Loose coupling                       Tight coupling
●
    Immutability                Mutable data structures
●
    Encapsulation                          Tramp data
●   Short code blocks        Monster functions/methods
●   Appropriate typing           String/Integer overuse
●
    Duplication avoidance                   Copy-Paste
●   Simplicity                        Over-engineering
●
    Consistent terminology            Mixture of terms
●   Clear naming                     Runtime surprises
Let's get to business!
●   Next slides describe problems
       – What is given
          (existing code)
       – What we want to achieve
          (using a pattern)

●
    As usual, the code is on github:
       http://github.com/angryziber/patterns
Problem 1: Pizza
●
    We have:
    –   A pizzeria
    –   Multitude of options for pizzas: name, toppings,
        thickness, size, delivery address, etc
●   We want:
    –   Allow users to “order” custom pizzas
    –   Disallow changing the order once the pizza is
        already in the oven
    –   Keep the ordering code readable
Problem 2: Unzipper
●
    We have:
    –   unzip() method
    –   It is able to decompress a single compressed
        stream
●   We need:
    –   Support multiple-volume archives
    –   Compressed data is split into multiple floppies
Problem 3: Maps
●
    We have:
    –   Map data of entire Tallinn with all the streets,
        buildings, etc
    –   The MapVisualizer class that can draw the full map
        on the screen
●
    We want:
    –   User to see only a section of the map at any given
        time
    –   User to be able to move around the map
Problem 4: CD Player
●
    We have:
    –   A CD player with buttons play, stop, next, eject
●
    We want:
    –   Play to switch the player on
    –   Play again to pause playback, again to resume
    –   Stop to turn off the player
    –   Eject to open the disk tray (if no disk – no playback
        possible)
    –   etc, etc, etc
Problem 5: Vending Machine
●
    We have:
    –   A vending machine that can sell any small enough
        items
●
    We want:
    –   To deploy several such machines selling bottles of
        pepsi, sushi boxes, and Hintai magazines
    –   Each machine to sell items of one type
Problem 6: Spreadsheet
●
    We have:
    –   A spreadsheet-type program
    –   Containing a table for entering data and formulas
●   We want:
    –   The program to support charts
    –   The charts to be updated automatically if user
        changes the data in the table
    –   To sell the chart add-on separately for only $99.99
Problem 7: Battlefield
●
    We have:
    –   A tank
    –   Several types of bullets
    –   Lots of enemies around, e.g. airplanes, other
        tanks, guys with Molotov-coctails
●
    We want:
    –   To survive
    –   To kill 'em all
Problem 8: TCP over DNS
●
    We have:
    –    A paid Wi-Fi network (e.g. in an airport)
    –    Lots of spare time, but no credit card
●   We want:
    –    To be able to read emails and surf Facebook
    –    (Most likely, during our next trip)
●   Background info:
     –   Paid Wi-Fi usually resolves DNS just fine
     –   DNS packets can contain any payload
Thank you!




Codeborne is the only true extreme
programming company in the region.

Come and join us for an experience of
a lifetime you can't find elsewhere!

                job@codeborne.com

More Related Content

PDF
Database Refactoring
PDF
Cloud Best Practices
PDF
Simple Pure Java
PDF
Being a professional software tester
PDF
Scrum is not enough - being a successful agile engineer
PDF
The Top 30 LotusScript Development Tips
PDF
Test driven development - Zombie proof your code
Database Refactoring
Cloud Best Practices
Simple Pure Java
Being a professional software tester
Scrum is not enough - being a successful agile engineer
The Top 30 LotusScript Development Tips
Test driven development - Zombie proof your code

What's hot (13)

PDF
Top Tips Every Notes Developer Needs To Know
PDF
Making Strongly-typed NETCONF Usable
PDF
Detangling Your JavaScript
PDF
J9: Under the hood of the next open source JVM
PPTX
XPDays Ukraine: Legacy
PDF
It's all about behaviour, also in php - phpspec
PDF
Refactoring Legacy Code
PDF
Test Driven Development Powered by LEGO
KEY
Javascript Tests with Jasmine for Front-end Devs
PDF
invokedynamic: Evolution of a Language Feature
PDF
Oh the compilers you'll build
PPTX
How we tested our code "Google way"
PPTX
FOSDEM 2017 - Open J9 The Next Free Java VM
Top Tips Every Notes Developer Needs To Know
Making Strongly-typed NETCONF Usable
Detangling Your JavaScript
J9: Under the hood of the next open source JVM
XPDays Ukraine: Legacy
It's all about behaviour, also in php - phpspec
Refactoring Legacy Code
Test Driven Development Powered by LEGO
Javascript Tests with Jasmine for Front-end Devs
invokedynamic: Evolution of a Language Feature
Oh the compilers you'll build
How we tested our code "Google way"
FOSDEM 2017 - Open J9 The Next Free Java VM
Ad

Similar to Choose a pattern for a problem (20)

PDF
Design Patterns Summer Course 2009-2010 - Session#1
PPTX
Software Engineer- A unity 3d Game
PPTX
Design Patterns- Course for students .pptx
PDF
Design Patterns Illustrated
PPT
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
PDF
OpenThink Labs Training : Diving into Java, The Head First Way
PPTX
Building blocks (Game Architecture)
PPT
Unit4
PDF
Dimitry Solovyov - The imminent threat of functional programming
PDF
Design patterns for fun & profit - CoderCruise 2018
PPTX
06 fse design
PDF
ABSE and AtomWeaver : A Quantum Leap in Software Development
PDF
Designing for Tomorrow, Delivering Today
PPTX
Software Design
PDF
Prototyping in code
PPT
3.3 programming fundamentals
PDF
Evolving Software Patterns
PDF
Cse 6007 fall2012
PDF
(E book pdf) thinking in patterns with java
PDF
Framework Engineering
Design Patterns Summer Course 2009-2010 - Session#1
Software Engineer- A unity 3d Game
Design Patterns- Course for students .pptx
Design Patterns Illustrated
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
OpenThink Labs Training : Diving into Java, The Head First Way
Building blocks (Game Architecture)
Unit4
Dimitry Solovyov - The imminent threat of functional programming
Design patterns for fun & profit - CoderCruise 2018
06 fse design
ABSE and AtomWeaver : A Quantum Leap in Software Development
Designing for Tomorrow, Delivering Today
Software Design
Prototyping in code
3.3 programming fundamentals
Evolving Software Patterns
Cse 6007 fall2012
(E book pdf) thinking in patterns with java
Framework Engineering
Ad

More from Anton Keks (16)

PDF
Java Course 14: Beans, Applets, GUI
PDF
Java Course 13: JDBC & Logging
PDF
Java Course 12: XML & XSL, Web & Servlets
PDF
Java Course 11: Design Patterns
PDF
Java Course 10: Threads and Concurrency
PDF
Java Course 9: Networking and Reflection
PDF
Java Course 8: I/O, Files and Streams
PDF
Java Course 7: Text processing, Charsets & Encodings
PDF
Java Course 6: Introduction to Agile
PDF
Java Course 5: Enums, Generics, Assertions
PDF
Java Course 4: Exceptions & Collections
PDF
Java Course 3: OOP
PDF
Java Course 2: Basics
PDF
Java Course 1: Introduction
PDF
Java Course 15: Ant, Scripting, Spring, Hibernate
PDF
Being a Professional Software Developer
Java Course 14: Beans, Applets, GUI
Java Course 13: JDBC & Logging
Java Course 12: XML & XSL, Web & Servlets
Java Course 11: Design Patterns
Java Course 10: Threads and Concurrency
Java Course 9: Networking and Reflection
Java Course 8: I/O, Files and Streams
Java Course 7: Text processing, Charsets & Encodings
Java Course 6: Introduction to Agile
Java Course 5: Enums, Generics, Assertions
Java Course 4: Exceptions & Collections
Java Course 3: OOP
Java Course 2: Basics
Java Course 1: Introduction
Java Course 15: Ant, Scripting, Spring, Hibernate
Being a Professional Software Developer

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
cuic standard and advanced reporting.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Electronic commerce courselecture one. Pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPT
Teaching material agriculture food technology
PPTX
A Presentation on Artificial Intelligence
Encapsulation_ Review paper, used for researhc scholars
cuic standard and advanced reporting.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Diabetes mellitus diagnosis method based random forest with bat algorithm
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Big Data Technologies - Introduction.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Mobile App Security Testing_ A Comprehensive Guide.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation theory and applications.pdf
Approach and Philosophy of On baking technology
Electronic commerce courselecture one. Pdf
NewMind AI Weekly Chronicles - August'25 Week I
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Monthly Chronicles - July 2025
Building Integrated photovoltaic BIPV_UPV.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Teaching material agriculture food technology
A Presentation on Artificial Intelligence

Choose a pattern for a problem

  • 1. Agile Saturday VI Choose a pattern for a problem! Anton Keks anton@codeborne.com
  • 2. The Increasing Complexity Complexity of software systems Time New programming paradigms Higher level of abstraction HW Assembler Structural (objects+functions?) CPUs Procedural <OOP> ...
  • 3. What are design patterns? ● Anywhere in the world you can find recurring patterns ● Design patterns – are building blocks of a system's architecture – are recurring solutions to design problems that you see over – identify and specify abstractions that are above the level of single classes and instances
  • 4. Pattern classification The GOF book defines 3 major types of patterns: – Creational patterns – substitute the new keyword. This gives your program more flexibility in deciding which objects need to be created for a given case – Structural patterns - compose groups of objects into larger structures, such as complex user interfaces or accounting data – Behavioral patterns - define the communication between objects and how the flow is controlled in a complex program.
  • 5. Decorator Adapter Composite Strategy State Observer Factory Iterator Builder Prototype
  • 6. Software Design: The Good ● Loose coupling ● Immutability ● Encapsulation ● Short code blocks ● Appropriate typing ● Duplication avoidance ● Simplicity ● Consistent terminology ● Clear naming
  • 7. Bad, bad, bad! ● Loose coupling Tight coupling ● Immutability Mutable data structures ● Encapsulation Tramp data ● Short code blocks Monster functions/methods ● Appropriate typing String/Integer overuse ● Duplication avoidance Copy-Paste ● Simplicity Over-engineering ● Consistent terminology Mixture of terms ● Clear naming Runtime surprises
  • 8. Let's get to business! ● Next slides describe problems – What is given (existing code) – What we want to achieve (using a pattern) ● As usual, the code is on github: http://github.com/angryziber/patterns
  • 9. Problem 1: Pizza ● We have: – A pizzeria – Multitude of options for pizzas: name, toppings, thickness, size, delivery address, etc ● We want: – Allow users to “order” custom pizzas – Disallow changing the order once the pizza is already in the oven – Keep the ordering code readable
  • 10. Problem 2: Unzipper ● We have: – unzip() method – It is able to decompress a single compressed stream ● We need: – Support multiple-volume archives – Compressed data is split into multiple floppies
  • 11. Problem 3: Maps ● We have: – Map data of entire Tallinn with all the streets, buildings, etc – The MapVisualizer class that can draw the full map on the screen ● We want: – User to see only a section of the map at any given time – User to be able to move around the map
  • 12. Problem 4: CD Player ● We have: – A CD player with buttons play, stop, next, eject ● We want: – Play to switch the player on – Play again to pause playback, again to resume – Stop to turn off the player – Eject to open the disk tray (if no disk – no playback possible) – etc, etc, etc
  • 13. Problem 5: Vending Machine ● We have: – A vending machine that can sell any small enough items ● We want: – To deploy several such machines selling bottles of pepsi, sushi boxes, and Hintai magazines – Each machine to sell items of one type
  • 14. Problem 6: Spreadsheet ● We have: – A spreadsheet-type program – Containing a table for entering data and formulas ● We want: – The program to support charts – The charts to be updated automatically if user changes the data in the table – To sell the chart add-on separately for only $99.99
  • 15. Problem 7: Battlefield ● We have: – A tank – Several types of bullets – Lots of enemies around, e.g. airplanes, other tanks, guys with Molotov-coctails ● We want: – To survive – To kill 'em all
  • 16. Problem 8: TCP over DNS ● We have: – A paid Wi-Fi network (e.g. in an airport) – Lots of spare time, but no credit card ● We want: – To be able to read emails and surf Facebook – (Most likely, during our next trip) ● Background info: – Paid Wi-Fi usually resolves DNS just fine – DNS packets can contain any payload
  • 17. Thank you! Codeborne is the only true extreme programming company in the region. Come and join us for an experience of a lifetime you can't find elsewhere! job@codeborne.com