SlideShare a Scribd company logo
1 of 45
Download to read offline
AMIR BARYLKO
                  ADVANCED
               DESIGN PATTERNS


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 Desing Patterns
RESOURCES

  • Email: amir@barylko.com

  • Twitter: @abarylko

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

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




Amir Barylko                                      Advanced Desing 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            •   Composite
                             Comprehension
  •   Proxy                                  •   State
                         •   Object Mother
  •   ActiveRecord                           •   Strategy
                         •   Visitor
  •   Repository                             •   Iterator
                         •   Null Object
  •   Event Aggregator                       •   DTO
                         •   Factory
  •   Event Sourcing                         •   Page Object
                         •   Command
Amir Barylko                                         Advanced Desing 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 Desing Patterns
RESOURCES III




Amir Barylko                   Advanced Desing Patterns
CLOJURE TRAINING

  • When: Nov       6, 7 & 8

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

  • Goal: LearnClojure and functional programming with real
    hands on examples




Amir Barylko                                      Advanced Desing Patterns

More Related Content

Viewers also liked

T bunio active-architecture
T bunio active-architectureT bunio active-architecture
T bunio active-architecturesdeconf
 
Sdec11.agile ina day
Sdec11.agile ina daySdec11.agile ina day
Sdec11.agile ina daysdeconf
 
Bai 50 he sinh thai
Bai 50 he sinh thaiBai 50 he sinh thai
Bai 50 he sinh thaiThao Nguyen
 
J wagner security
J wagner securityJ wagner security
J wagner securitysdeconf
 
Friesens agile adoption
Friesens agile adoptionFriesens agile adoption
Friesens agile adoptionsdeconf
 
D alpert ux102
D alpert ux102D alpert ux102
D alpert ux102sdeconf
 

Viewers also liked (7)

Capítulo 2 css
Capítulo 2 cssCapítulo 2 css
Capítulo 2 css
 
T bunio active-architecture
T bunio active-architectureT bunio active-architecture
T bunio active-architecture
 
Sdec11.agile ina day
Sdec11.agile ina daySdec11.agile ina day
Sdec11.agile ina day
 
Bai 50 he sinh thai
Bai 50 he sinh thaiBai 50 he sinh thai
Bai 50 he sinh thai
 
J wagner security
J wagner securityJ wagner security
J wagner security
 
Friesens agile adoption
Friesens agile adoptionFriesens agile adoption
Friesens agile adoption
 
D alpert ux102
D alpert ux102D alpert ux102
D alpert ux102
 

Similar to A baryklo design-patterns

PRDCW-advanced-design-patterns
PRDCW-advanced-design-patternsPRDCW-advanced-design-patterns
PRDCW-advanced-design-patternsAmir Barylko
 
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
 
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 patterns Java EE revisits design patterns
Java EE revisits design patterns Alex 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
 
Java EE Revisits Design Patterns
Java EE Revisits Design PatternsJava EE Revisits Design Patterns
Java EE Revisits Design PatternsAlex Theedom
 
44 Slides About 22 Modules
44 Slides About 22 Modules44 Slides About 22 Modules
44 Slides About 22 Modulesheyrocker
 
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
 
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
 
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
 
Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2Julie Iskander
 
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
 
Spring framework
Spring frameworkSpring framework
Spring frameworkAircon Chen
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and ActivatorKevin Webber
 
SAP ABAP + CRM7.0 with Course Content
SAP ABAP + CRM7.0 with Course ContentSAP ABAP + CRM7.0 with Course Content
SAP ABAP + CRM7.0 with Course ContentChoodamani Infotech
 
Hidden Treasure - TestComplete Script Extensions
Hidden Treasure - TestComplete Script ExtensionsHidden Treasure - TestComplete Script Extensions
Hidden Treasure - TestComplete Script ExtensionsSmartBear
 

Similar to A baryklo design-patterns (20)

PRDCW-advanced-design-patterns
PRDCW-advanced-design-patternsPRDCW-advanced-design-patterns
PRDCW-advanced-design-patterns
 
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
 
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 patterns Java EE revisits design patterns
Java EE revisits design patterns
 
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
 
Java EE Revisits Design Patterns
Java EE Revisits Design PatternsJava EE Revisits Design Patterns
Java EE Revisits Design Patterns
 
44 Slides About 22 Modules
44 Slides About 22 Modules44 Slides About 22 Modules
44 Slides About 22 Modules
 
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
 
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
 
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
 
Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2
 
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
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
SAP ABAP + CRM7.0 with Course Content
SAP ABAP + CRM7.0 with Course ContentSAP ABAP + CRM7.0 with Course Content
SAP ABAP + CRM7.0 with Course Content
 
Hidden Treasure - TestComplete Script Extensions
Hidden Treasure - TestComplete Script ExtensionsHidden Treasure - TestComplete Script Extensions
Hidden Treasure - TestComplete Script Extensions
 

More from sdeconf

S rogalsky user-storymapping
S rogalsky user-storymappingS rogalsky user-storymapping
S rogalsky user-storymappingsdeconf
 
Sdec 2011 ux_agile_svt
Sdec 2011 ux_agile_svtSdec 2011 ux_agile_svt
Sdec 2011 ux_agile_svtsdeconf
 
Sdec 2011 ask_watchlisten_svt
Sdec 2011 ask_watchlisten_svtSdec 2011 ask_watchlisten_svt
Sdec 2011 ask_watchlisten_svtsdeconf
 
S bueckert sdecmobile
S bueckert sdecmobileS bueckert sdecmobile
S bueckert sdecmobilesdeconf
 
Rackforce the cloud
Rackforce the cloudRackforce the cloud
Rackforce the cloudsdeconf
 
Pscad agile adoption
Pscad agile adoptionPscad agile adoption
Pscad agile adoptionsdeconf
 
L phillips apm
L phillips apmL phillips apm
L phillips apmsdeconf
 
G meredith scala
G meredith scalaG meredith scala
G meredith scalasdeconf
 
Dan perron lim
Dan perron limDan perron lim
Dan perron limsdeconf
 
D alpert ux101
D alpert ux101D alpert ux101
D alpert ux101sdeconf
 
C maksymchuk android
C maksymchuk androidC maksymchuk android
C maksymchuk androidsdeconf
 
C fowler intro-azure
C fowler intro-azureC fowler intro-azure
C fowler intro-azuresdeconf
 
C fowler azure-dojo
C fowler azure-dojoC fowler azure-dojo
C fowler azure-dojosdeconf
 
Booked in agileadoption
Booked in agileadoptionBooked in agileadoption
Booked in agileadoptionsdeconf
 

More from sdeconf (14)

S rogalsky user-storymapping
S rogalsky user-storymappingS rogalsky user-storymapping
S rogalsky user-storymapping
 
Sdec 2011 ux_agile_svt
Sdec 2011 ux_agile_svtSdec 2011 ux_agile_svt
Sdec 2011 ux_agile_svt
 
Sdec 2011 ask_watchlisten_svt
Sdec 2011 ask_watchlisten_svtSdec 2011 ask_watchlisten_svt
Sdec 2011 ask_watchlisten_svt
 
S bueckert sdecmobile
S bueckert sdecmobileS bueckert sdecmobile
S bueckert sdecmobile
 
Rackforce the cloud
Rackforce the cloudRackforce the cloud
Rackforce the cloud
 
Pscad agile adoption
Pscad agile adoptionPscad agile adoption
Pscad agile adoption
 
L phillips apm
L phillips apmL phillips apm
L phillips apm
 
G meredith scala
G meredith scalaG meredith scala
G meredith scala
 
Dan perron lim
Dan perron limDan perron lim
Dan perron lim
 
D alpert ux101
D alpert ux101D alpert ux101
D alpert ux101
 
C maksymchuk android
C maksymchuk androidC maksymchuk android
C maksymchuk android
 
C fowler intro-azure
C fowler intro-azureC fowler intro-azure
C fowler intro-azure
 
C fowler azure-dojo
C fowler azure-dojoC fowler azure-dojo
C fowler azure-dojo
 
Booked in agileadoption
Booked in agileadoptionBooked in agileadoption
Booked in agileadoption
 

Recently uploaded

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
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 SolutionsEnterprise Knowledge
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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 textsMaria Levchenko
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 

Recently uploaded (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I 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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 

A baryklo design-patterns

  • 1. AMIR BARYLKO ADVANCED DESIGN PATTERNS 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 Desing Patterns
  • 3. RESOURCES • Email: amir@barylko.com • Twitter: @abarylko • Blog: http://www.orthocoders.com • Materials: http://www.orthocoders.com/presentations Amir Barylko Advanced Desing 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 • Composite Comprehension • Proxy • State • Object Mother • ActiveRecord • Strategy • Visitor • Repository • Iterator • Null Object • Event Aggregator • DTO • Factory • Event Sourcing • Page Object • Command Amir Barylko Advanced Desing 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 Desing Patterns
  • 44. RESOURCES III Amir Barylko Advanced Desing Patterns
  • 45. CLOJURE TRAINING • When: Nov 6, 7 & 8 • More info: http://www.maventhought.com • Goal: LearnClojure and functional programming with real hands on examples Amir Barylko Advanced Desing Patterns