SlideShare una empresa de Scribd logo
1 de 45
Descargar para leer sin conexión
AMIR BARYLKO
                  ADVANCED
               DESIGN	
  PATTERNS

                WINNIPEG CODECAMP
                     FEB 2012



Amir Barylko                        Advanced Design Patterns
WHO AM I?

  • Software     quality expert

  • Architect

  • Developer

  • Mentor

  • Great      cook

  • The    one who’s entertaining you for the next hour!
Amir Barylko                                          Advanced Design Patterns
RESOURCES

  • Email: amir@barylko.com

  • Twitter: @abarylko

  • Blog: http://www.orthocoders.com

  • Materials: http://www.orthocoders.com/presentations




Amir Barylko                                      Advanced Design Patterns
PATTERNS
                    What are they?
                What are anti-patterns?
               Which patterns do you use?




Amir Barylko                                Advanced Design Patterns
WHAT ARE PATTERNS?

  •Software         design Recipe
  •or     Solution
  •Should         be reusable
  •Should         be general
  •No          particular language
Amir Barylko                         Advanced Design Patterns
ANTI-PATTERNS
  •   More patterns != better design

  •   No cookie cutter

  •   Anti Patterns : Patterns to identify failure

      •   God Classes

      •   High Coupling

      •   Breaking SOLID principles....

      •   (name some)
Amir Barylko                                         Advanced Design Patterns
WHICH PATTERNS
                   DO YOU USE?
  • Fill   here with your patterns:




Amir Barylko                          Advanced Design Patterns
ADVANCED PATTERNS
                     Let’s vote!




Amir Barylko                       Advanced Design Patterns
SOME PATTERNS...

  • Chain      of resp.   • List               • Strategy
                           Comprehension
  • Proxy                                      • DTO
                          • Object    Mother
  • ActiveRecord                               • Page   Object
                          • Visitor
  • Repository
                          • Null   Object
  • Event Aggregator
                          • Factory
  • Event      Sourcing
Amir Barylko                                        Advanced Design Patterns
CHAIN OF RESPONSIBILITY

  • More   than one object may handle a request, and the handler
    isn't known a priori.

  • The    handler should be ascertained automatically.

  • You want to issue request to one of several objects without
    specifying The receiver explicitly.

  • The set of objects that can handle a request should be
    specified dynamically

Amir Barylko                                          Advanced Design Patterns
Amir Barylko   Advanced Design Patterns
PROXY

  • Avoid       creating the object until needed

  • Provides      a placeholder for additional functionality

  • Very       useful for mocking

  • Many       implementations exist (IoC, Dynamic proxies, etc)




Amir Barylko                                               Advanced Design Patterns
GOF
ACTIVERECORD

  • Isa Domain Model where classes match very closely the
    database structure

  • Each table is mapped to class with methods for finding,
    update, delete, etc.

  • Each       attribute is mapped to a column

  • Associations      are deduced from the classes


Amir Barylko                                         Advanced Design Patterns
create_table   "movies", :force => true do |t|
    t.string     "title"
    t.string     "description"
    t.datetime   "created_at"
    t.datetime   "updated_at"
  end

  create_table   "reviews", :force => true do |t|
    t.string     "name"
    t.integer    "stars"
    t.text       "comment"
    t.integer    "movie_id"
    t.datetime   "created_at"
    t.datetime   "updated_at"
  end

   class Movie < ActiveRecord::Base
     validates_presence_of :title, :description
     has_many :reviews
   end
   class Review < ActiveRecord::Base
     belongs_to :movie
   end


Amir Barylko                                        Advanced Design Patterns
REPOSITORY

  • Mediator        between domain and storage

  • Acts       like a collection of items

  • Supports        queries

  • Abstraction       of the storage




Amir Barylko                                     Advanced Design Patterns
http://martinfowler.com/eaaCatalog/repository.html
Amir Barylko                                     Advanced Design Patterns
EVENT AGGREGATOR

  • Manage      events using a subscribe / publish mechanism

  • Isolates   subscribers from publishers

  • Decouple      events from actual models

  • Events     can be distributed

  • Centralize    event registration logic

  • No    need to track multiple objects
Amir Barylko                                           Advanced Design Patterns
Channel events
  from multiple
  objects into a
  single object to
  s i m p l i f y
  registration for
  clients



Amir Barylko         Advanced Design Patterns
MT COMMONS




Amir Barylko                Advanced Design Patterns
EVENT SOURCING

  • Register     all changes in the application using events

  • Event      should be persisted

  • Complete       Rebuild

  • Temporal      Query

  • Event      Replay


Amir Barylko                                              Advanced Design Patterns
http://martinfowler.com/eaaDev/EventSourcing.html
Amir Barylko                                    Advanced Design Patterns
Amir Barylko   Advanced Design Patterns
LIST COMPREHENSION

  • Syntax      Construct in languages

  • Describe      properties for the list (sequence)

  • Filter

  • Mapping

  • Same       idea for Set or Dictionary comprehension


Amir Barylko                                              Advanced Design Patterns
LANGUAGE COMPARISON
  • Scala
   for (x <- Stream.from(0); if x*x > 3) yield 2*x

  • LINQ
   var range = Enumerable.Range(0..20);
   from num in range where num * num > 3 select num * 2;

  • Clojure
   (take 20 (for [x (iterate inc 0) :when (> (* x x) 3)] (* 2 x)))


  • Ruby
   (1..20).select { |x| x * x > 3 }.map { |x| x * 2 }


Amir Barylko                                          Advanced Design Patterns
OBJECT MOTHER / BUILDER

  • Creates       an object for testing (or other) purposes

  • Assumes        defaults

  • Easy    to configure

  • Fluid      interface

  • Usually      has methods to to easily manipulate the domain


Amir Barylko                                              Advanced Design Patterns
public class When_adding_a_an_invalid_extra_frame
   {
       [Test]
       public void Should_throw_an_exception()
       {
           // arrange
           10.Times(() => this.GameBuilder.AddFrame(5, 4));

               var game = this.GameBuilder.Build();

               // act & assert
               new Action(() => game.Roll(8)).Should().Throw();
         }
   }




               http://orthocoders.com/2011/09/05/the-bowling-game-kata-first-attempt/


Amir Barylko                                                                Advanced Design Patterns
Amir Barylko   Advanced Design Patterns
VISITOR

  • Ability    to traverse (visit) a object structure

  • Different     visitors may produce different results

  • Avoid      littering the classes with particular operations




Amir Barylko                                               Advanced Design Patterns
http://en.wikipedia.org/wiki/Visitor_pattern#Diagram

Amir Barylko                                     Advanced Design Patterns
NULL OBJECT

  • Represent “null” with      an actual instance

  • Provides      default functionality

  • Clear      semantics of “null” for that domain




Amir Barylko                                         Advanced Design Patterns
class animal {
    public:
       virtual void make_sound() = 0;
    };

    class dog : public animal {
       void make_sound() { cout << "woof!" << endl; }
    };

    class null_animal : public animal {
       void make_sound() { }
    };




           http://en.wikipedia.org/wiki/Null_Object_pattern


Amir Barylko                                      Advanced Design Patterns
FACTORY

  • Creates      instances by request

  • More       flexible than Singleton

  • Can    be configured to create different families of objects

  • IoC    containers are closely related

  • Can    be implemented dynamic based on interfaces

  • Can    be used also to release “resource” when not needed
Amir Barylko                                           Advanced Design Patterns
interface GUIFactory {
       public Button createButton();
   }

   class WinFactory implements GUIFactory {
       public Button createButton() {
           return new WinButton();
       }
   }
   class OSXFactory implements GUIFactory {
       public Button createButton() {
           return new OSXButton();
       }
   }

   interface Button {
       public void paint();
   }
      http://en.wikipedia.org/wiki/Abstract_factory_pattern

Amir Barylko                                    Advanced Design Patterns
STRATEGY

  • Abstracts   the algorithm to solve a particular problem

  • Can    be configured dynamically

  • Are    interchangeable




Amir Barylko                                          Advanced Design Patterns
http://orthocoders.com/2010/04/
Amir Barylko                                     Advanced Design Patterns
DATA TRANSFER OBJECT

  • Simplifies   information transfer across services

  • Can    be optimized

  • Easy   to understand




Amir Barylko                                           Advanced Design Patterns
http://martinfowler.com/eaaCatalog/dataTransferObject.html

Amir Barylko                                 Advanced Design Patterns
PAGE OBJECT

  • Abstract      web pages functionality to be used usually in testing

  • Each       page can be reused

  • Changes       in the page impact only the implementation, not the
    clients




Amir Barylko                                              Advanced Design Patterns
public class LoginPage {
     public HomePage loginAs(String username, String password) {
         // ... clever magic happens here
     }
    
     public LoginPage loginWithError(String username, String
 password) {
         //  ... failed login here, maybe because
         // one or both of the username and password are wrong
     }
    
     public String getErrorMessage() {
         // So we can verify that the correct error is shown
     }
 }




       http://code.google.com/p/selenium/wiki/PageObjects


Amir Barylko                                         Advanced Design Patterns
QUESTIONS?




Amir Barylko                Advanced Design Patterns
RESOURCES

  • Email: amir@barylko.com, @abarylko

  • Slides: http://www.orthocoders.com/presentations

  • Patterns: Each   pattern example has a link




Amir Barylko                                      Advanced Design Patterns
RESOURCES II




Amir Barylko                  Advanced Design Patterns
RESOURCES III




Amir Barylko                   Advanced Design Patterns
QUALITY SOFTWARE
                    TRAINING
  • Topics: Kanban,    BDD & TDD.

  • When: May       6, 11-12 & 17-18

  • More       info: http://www.maventhought.com

  • Goal: Learn  techniques, methodologies and tools to improve
    the quality in your day to day job.



Amir Barylko                                       Advanced Design Patterns

Más contenido relacionado

Similar a Code camp 2012-advanced-design-patterns

DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻都元ダイスケ Miyamoto
 
SE2016 - Java EE revisits design patterns 2016
SE2016 - Java EE revisits design patterns 2016SE2016 - Java EE revisits design patterns 2016
SE2016 - Java EE revisits design patterns 2016Alex Theedom
 
Codestrong 2012 breakout session how to develop your own modules
Codestrong 2012 breakout session   how to develop your own modulesCodestrong 2012 breakout session   how to develop your own modules
Codestrong 2012 breakout session how to develop your own modulesAxway Appcelerator
 
Introduction to Module Development with Appcelerator Titanium
Introduction to Module Development with Appcelerator TitaniumIntroduction to Module Development with Appcelerator Titanium
Introduction to Module Development with Appcelerator TitaniumAaron Saunders
 
Rich UI with Knockout.js &amp; Coffeescript
Rich UI with Knockout.js &amp; CoffeescriptRich UI with Knockout.js &amp; Coffeescript
Rich UI with Knockout.js &amp; CoffeescriptAmir Barylko
 
Java EE revisits design patterns
Java EE revisits design patterns Java EE revisits design patterns
Java EE revisits design patterns Alex Theedom
 
Java EE revisits design patterns
Java EE revisits design patternsJava EE revisits design patterns
Java EE revisits design patternsAlex Theedom
 
Java EE Revisits Design Patterns
Java EE Revisits Design PatternsJava EE Revisits Design Patterns
Java EE Revisits Design PatternsAlex Theedom
 
PLAT-20 Building Alfresco Prototypes in a Few Hours
PLAT-20 Building Alfresco Prototypes in a Few HoursPLAT-20 Building Alfresco Prototypes in a Few Hours
PLAT-20 Building Alfresco Prototypes in a Few HoursAlfresco Software
 
44 Slides About 22 Modules
44 Slides About 22 Modules44 Slides About 22 Modules
44 Slides About 22 Modulesheyrocker
 
Ro r trilogy-part-1
Ro r trilogy-part-1Ro r trilogy-part-1
Ro r trilogy-part-1sdeconf
 
sdec11-ror-trilogy-part1
sdec11-ror-trilogy-part1sdec11-ror-trilogy-part1
sdec11-ror-trilogy-part1Amir Barylko
 
PRDC-ror-trilogy-part1
PRDC-ror-trilogy-part1PRDC-ror-trilogy-part1
PRDC-ror-trilogy-part1Amir Barylko
 
SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"Inhacking
 
Page objects pattern
Page objects patternPage objects pattern
Page objects patternAmir Barylko
 
Page-objects-pattern
Page-objects-patternPage-objects-pattern
Page-objects-patternAmir Barylko
 
Open source libraries and tools
Open source libraries and toolsOpen source libraries and tools
Open source libraries and toolsAmir Barylko
 
Hidden Treasure - TestComplete Script Extensions
Hidden Treasure - TestComplete Script ExtensionsHidden Treasure - TestComplete Script Extensions
Hidden Treasure - TestComplete Script ExtensionsSmartBear
 

Similar a Code camp 2012-advanced-design-patterns (20)

DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻
 
SE2016 - Java EE revisits design patterns 2016
SE2016 - Java EE revisits design patterns 2016SE2016 - Java EE revisits design patterns 2016
SE2016 - Java EE revisits design patterns 2016
 
Codestrong 2012 breakout session how to develop your own modules
Codestrong 2012 breakout session   how to develop your own modulesCodestrong 2012 breakout session   how to develop your own modules
Codestrong 2012 breakout session how to develop your own modules
 
Introduction to Module Development with Appcelerator Titanium
Introduction to Module Development with Appcelerator TitaniumIntroduction to Module Development with Appcelerator Titanium
Introduction to Module Development with Appcelerator Titanium
 
Rich UI with Knockout.js &amp; Coffeescript
Rich UI with Knockout.js &amp; CoffeescriptRich UI with Knockout.js &amp; Coffeescript
Rich UI with Knockout.js &amp; Coffeescript
 
Java EE revisits design patterns
Java EE revisits design patterns Java EE revisits design patterns
Java EE revisits design patterns
 
Java EE revisits design patterns
Java EE revisits design patternsJava EE revisits design patterns
Java EE revisits design patterns
 
Java EE Revisits Design Patterns
Java EE Revisits Design PatternsJava EE Revisits Design Patterns
Java EE Revisits Design Patterns
 
PLAT-20 Building Alfresco Prototypes in a Few Hours
PLAT-20 Building Alfresco Prototypes in a Few HoursPLAT-20 Building Alfresco Prototypes in a Few Hours
PLAT-20 Building Alfresco Prototypes in a Few Hours
 
44 Slides About 22 Modules
44 Slides About 22 Modules44 Slides About 22 Modules
44 Slides About 22 Modules
 
Ro r trilogy-part-1
Ro r trilogy-part-1Ro r trilogy-part-1
Ro r trilogy-part-1
 
sdec11-ror-trilogy-part1
sdec11-ror-trilogy-part1sdec11-ror-trilogy-part1
sdec11-ror-trilogy-part1
 
PRDC-ror-trilogy-part1
PRDC-ror-trilogy-part1PRDC-ror-trilogy-part1
PRDC-ror-trilogy-part1
 
SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"
 
Alex Theedom Java ee revisits design patterns
Alex Theedom	Java ee revisits design patternsAlex Theedom	Java ee revisits design patterns
Alex Theedom Java ee revisits design patterns
 
Page objects pattern
Page objects patternPage objects pattern
Page objects pattern
 
Page-objects-pattern
Page-objects-patternPage-objects-pattern
Page-objects-pattern
 
Open source libraries and tools
Open source libraries and toolsOpen source libraries and tools
Open source libraries and tools
 
Hidden Treasure - TestComplete Script Extensions
Hidden Treasure - TestComplete Script ExtensionsHidden Treasure - TestComplete Script Extensions
Hidden Treasure - TestComplete Script Extensions
 
YEG-UG-Capybara
YEG-UG-CapybaraYEG-UG-Capybara
YEG-UG-Capybara
 

Más de Amir Barylko

Functional converter project
Functional converter projectFunctional converter project
Functional converter projectAmir Barylko
 
Elm: delightful web development
Elm: delightful web developmentElm: delightful web development
Elm: delightful web developmentAmir Barylko
 
User stories deep dive
User stories deep diveUser stories deep dive
User stories deep diveAmir Barylko
 
Coderetreat hosting training
Coderetreat hosting trainingCoderetreat hosting training
Coderetreat hosting trainingAmir Barylko
 
There's no charge for (functional) awesomeness
There's no charge for (functional) awesomenessThere's no charge for (functional) awesomeness
There's no charge for (functional) awesomenessAmir Barylko
 
What's new in c# 6
What's new in c# 6What's new in c# 6
What's new in c# 6Amir Barylko
 
Who killed object oriented design?
Who killed object oriented design?Who killed object oriented design?
Who killed object oriented design?Amir Barylko
 
From coach to owner - What I learned from the other side
From coach to owner - What I learned from the other sideFrom coach to owner - What I learned from the other side
From coach to owner - What I learned from the other sideAmir Barylko
 
Communication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivityCommunication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivityAmir Barylko
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven DevelopmentAmir Barylko
 
Agile requirements
Agile requirementsAgile requirements
Agile requirementsAmir Barylko
 
Agile teams and responsibilities
Agile teams and responsibilitiesAgile teams and responsibilities
Agile teams and responsibilitiesAmir Barylko
 
Beutiful javascript with coffeescript
Beutiful javascript with coffeescriptBeutiful javascript with coffeescript
Beutiful javascript with coffeescriptAmir Barylko
 
Agile requirements
Agile requirementsAgile requirements
Agile requirementsAmir Barylko
 

Más de Amir Barylko (20)

Functional converter project
Functional converter projectFunctional converter project
Functional converter project
 
Elm: delightful web development
Elm: delightful web developmentElm: delightful web development
Elm: delightful web development
 
Dot Net Core
Dot Net CoreDot Net Core
Dot Net Core
 
No estimates
No estimatesNo estimates
No estimates
 
User stories deep dive
User stories deep diveUser stories deep dive
User stories deep dive
 
Coderetreat hosting training
Coderetreat hosting trainingCoderetreat hosting training
Coderetreat hosting training
 
There's no charge for (functional) awesomeness
There's no charge for (functional) awesomenessThere's no charge for (functional) awesomeness
There's no charge for (functional) awesomeness
 
What's new in c# 6
What's new in c# 6What's new in c# 6
What's new in c# 6
 
Productive teams
Productive teamsProductive teams
Productive teams
 
Who killed object oriented design?
Who killed object oriented design?Who killed object oriented design?
Who killed object oriented design?
 
From coach to owner - What I learned from the other side
From coach to owner - What I learned from the other sideFrom coach to owner - What I learned from the other side
From coach to owner - What I learned from the other side
 
Communication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivityCommunication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivity
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven Development
 
Refactoring
RefactoringRefactoring
Refactoring
 
Agile requirements
Agile requirementsAgile requirements
Agile requirements
 
Agile teams and responsibilities
Agile teams and responsibilitiesAgile teams and responsibilities
Agile teams and responsibilities
 
Refactoring
RefactoringRefactoring
Refactoring
 
Beutiful javascript with coffeescript
Beutiful javascript with coffeescriptBeutiful javascript with coffeescript
Beutiful javascript with coffeescript
 
Sass & bootstrap
Sass & bootstrapSass & bootstrap
Sass & bootstrap
 
Agile requirements
Agile requirementsAgile requirements
Agile requirements
 

Último

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Último (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Code camp 2012-advanced-design-patterns

  • 1. AMIR BARYLKO ADVANCED DESIGN  PATTERNS WINNIPEG CODECAMP FEB 2012 Amir Barylko Advanced Design Patterns
  • 2. WHO AM I? • Software quality expert • Architect • Developer • Mentor • Great cook • The one who’s entertaining you for the next hour! Amir Barylko Advanced Design Patterns
  • 3. RESOURCES • Email: amir@barylko.com • Twitter: @abarylko • Blog: http://www.orthocoders.com • Materials: http://www.orthocoders.com/presentations Amir Barylko Advanced Design Patterns
  • 4. PATTERNS What are they? What are anti-patterns? Which patterns do you use? Amir Barylko Advanced Design Patterns
  • 5. WHAT ARE PATTERNS? •Software design Recipe •or Solution •Should be reusable •Should be general •No particular language Amir Barylko Advanced Design Patterns
  • 6. ANTI-PATTERNS • More patterns != better design • No cookie cutter • Anti Patterns : Patterns to identify failure • God Classes • High Coupling • Breaking SOLID principles.... • (name some) Amir Barylko Advanced Design Patterns
  • 7. WHICH PATTERNS DO YOU USE? • Fill here with your patterns: Amir Barylko Advanced Design Patterns
  • 8. ADVANCED PATTERNS Let’s vote! Amir Barylko Advanced Design Patterns
  • 9. SOME PATTERNS... • Chain of resp. • List • Strategy Comprehension • Proxy • DTO • Object Mother • ActiveRecord • Page Object • Visitor • Repository • Null Object • Event Aggregator • Factory • Event Sourcing Amir Barylko Advanced Design Patterns
  • 10. CHAIN OF RESPONSIBILITY • More than one object may handle a request, and the handler isn't known a priori. • The handler should be ascertained automatically. • You want to issue request to one of several objects without specifying The receiver explicitly. • The set of objects that can handle a request should be specified dynamically Amir Barylko Advanced Design Patterns
  • 11. Amir Barylko Advanced Design Patterns
  • 12. PROXY • Avoid creating the object until needed • Provides a placeholder for additional functionality • Very useful for mocking • Many implementations exist (IoC, Dynamic proxies, etc) Amir Barylko Advanced Design Patterns
  • 13. GOF
  • 14. ACTIVERECORD • Isa Domain Model where classes match very closely the database structure • Each table is mapped to class with methods for finding, update, delete, etc. • Each attribute is mapped to a column • Associations are deduced from the classes Amir Barylko Advanced Design Patterns
  • 15. create_table "movies", :force => true do |t| t.string "title" t.string "description" t.datetime "created_at" t.datetime "updated_at" end create_table "reviews", :force => true do |t| t.string "name" t.integer "stars" t.text "comment" t.integer "movie_id" t.datetime "created_at" t.datetime "updated_at" end class Movie < ActiveRecord::Base validates_presence_of :title, :description has_many :reviews end class Review < ActiveRecord::Base belongs_to :movie end Amir Barylko Advanced Design Patterns
  • 16. REPOSITORY • Mediator between domain and storage • Acts like a collection of items • Supports queries • Abstraction of the storage Amir Barylko Advanced Design Patterns
  • 18. EVENT AGGREGATOR • Manage events using a subscribe / publish mechanism • Isolates subscribers from publishers • Decouple events from actual models • Events can be distributed • Centralize event registration logic • No need to track multiple objects Amir Barylko Advanced Design Patterns
  • 19. Channel events from multiple objects into a single object to s i m p l i f y registration for clients Amir Barylko Advanced Design Patterns
  • 20. MT COMMONS Amir Barylko Advanced Design Patterns
  • 21. EVENT SOURCING • Register all changes in the application using events • Event should be persisted • Complete Rebuild • Temporal Query • Event Replay Amir Barylko Advanced Design Patterns
  • 23. Amir Barylko Advanced Design Patterns
  • 24. LIST COMPREHENSION • Syntax Construct in languages • Describe properties for the list (sequence) • Filter • Mapping • Same idea for Set or Dictionary comprehension Amir Barylko Advanced Design Patterns
  • 25. LANGUAGE COMPARISON • Scala for (x <- Stream.from(0); if x*x > 3) yield 2*x • LINQ var range = Enumerable.Range(0..20); from num in range where num * num > 3 select num * 2; • Clojure (take 20 (for [x (iterate inc 0) :when (> (* x x) 3)] (* 2 x))) • Ruby (1..20).select { |x| x * x > 3 }.map { |x| x * 2 } Amir Barylko Advanced Design Patterns
  • 26. OBJECT MOTHER / BUILDER • Creates an object for testing (or other) purposes • Assumes defaults • Easy to configure • Fluid interface • Usually has methods to to easily manipulate the domain Amir Barylko Advanced Design Patterns
  • 27. public class When_adding_a_an_invalid_extra_frame { [Test] public void Should_throw_an_exception() { // arrange 10.Times(() => this.GameBuilder.AddFrame(5, 4)); var game = this.GameBuilder.Build(); // act & assert new Action(() => game.Roll(8)).Should().Throw(); } } http://orthocoders.com/2011/09/05/the-bowling-game-kata-first-attempt/ Amir Barylko Advanced Design Patterns
  • 28. Amir Barylko Advanced Design Patterns
  • 29. VISITOR • Ability to traverse (visit) a object structure • Different visitors may produce different results • Avoid littering the classes with particular operations Amir Barylko Advanced Design Patterns
  • 31. NULL OBJECT • Represent “null” with an actual instance • Provides default functionality • Clear semantics of “null” for that domain Amir Barylko Advanced Design Patterns
  • 32. class animal { public: virtual void make_sound() = 0; }; class dog : public animal { void make_sound() { cout << "woof!" << endl; } }; class null_animal : public animal { void make_sound() { } }; http://en.wikipedia.org/wiki/Null_Object_pattern Amir Barylko Advanced Design Patterns
  • 33. FACTORY • Creates instances by request • More flexible than Singleton • Can be configured to create different families of objects • IoC containers are closely related • Can be implemented dynamic based on interfaces • Can be used also to release “resource” when not needed Amir Barylko Advanced Design Patterns
  • 34. interface GUIFactory { public Button createButton(); } class WinFactory implements GUIFactory { public Button createButton() { return new WinButton(); } } class OSXFactory implements GUIFactory { public Button createButton() { return new OSXButton(); } } interface Button { public void paint(); } http://en.wikipedia.org/wiki/Abstract_factory_pattern Amir Barylko Advanced Design Patterns
  • 35. STRATEGY • Abstracts the algorithm to solve a particular problem • Can be configured dynamically • Are interchangeable Amir Barylko Advanced Design Patterns
  • 37. DATA TRANSFER OBJECT • Simplifies information transfer across services • Can be optimized • Easy to understand Amir Barylko Advanced Design Patterns
  • 39. PAGE OBJECT • Abstract web pages functionality to be used usually in testing • Each page can be reused • Changes in the page impact only the implementation, not the clients Amir Barylko Advanced Design Patterns
  • 40. public class LoginPage {     public HomePage loginAs(String username, String password) {         // ... clever magic happens here     }         public LoginPage loginWithError(String username, String password) {         //  ... failed login here, maybe because // one or both of the username and password are wrong     }         public String getErrorMessage() {         // So we can verify that the correct error is shown     } } http://code.google.com/p/selenium/wiki/PageObjects Amir Barylko Advanced Design Patterns
  • 41. QUESTIONS? Amir Barylko Advanced Design Patterns
  • 42. RESOURCES • Email: amir@barylko.com, @abarylko • Slides: http://www.orthocoders.com/presentations • Patterns: Each pattern example has a link Amir Barylko Advanced Design Patterns
  • 43. RESOURCES II Amir Barylko Advanced Design Patterns
  • 44. RESOURCES III Amir Barylko Advanced Design Patterns
  • 45. QUALITY SOFTWARE TRAINING • Topics: Kanban, BDD & TDD. • When: May 6, 11-12 & 17-18 • More info: http://www.maventhought.com • Goal: Learn techniques, methodologies and tools to improve the quality in your day to day job. Amir Barylko Advanced Design Patterns