SlideShare uma empresa Scribd logo
1 de 57
Baixar para ler 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 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. 18   • Event   Sourcing     • Null   Object
                              22
  • Proxy      1                                    • Factory    4
                             • List
  • ActiveRecord        12    Comprehension         • Strategy   11
                              1
  • Repository      5                               • DTO    4
                             • Object    Mother10
  • Event Aggregator                                • Page   Object 16
    26                       • Visitor   8

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
SnapToX



                  Next
                         SnapToY



                                   SnapToPrevious
                            Next




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




Amir Barylko         Advanced Design Patterns
PROXY SEQUENCE




Amir Barylko                Advanced Design Patterns
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
movie = Movie.new

   movie.all # all records

   # filter by title
   movie.where(title: 'Spaceballs')

   # finds by attribute
   movie.find_by_title('Blazing Saddles')

   # order, skip some and limit the result
   movie.order('title DESC').skip(2).limit(5)

   # associations CRUD
   movie.reviews.create(name: 'Jay Sherman',
                   stars: 1,
                   comment: 'It stinks!')


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
Amir Barylko   Advanced Design Patterns
http://martinfowler.com/eaaCatalog/repository.html
Amir Barylko                                     Advanced Design Patterns
ANTIPATTERN
         CHEAPER BY THE DOZEN




Amir Barylko             Advanced Design Patterns
WHAT TO DO?

  • Use    a criteria or better a queryable result (LINQ)

  • Use    a factory to return repositories

  • Use    a UnitOfWork with a factory




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
COUPLED




Amir Barylko             Advanced Design Patterns
DECOUPLED




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

  • Fluent     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
LINQ EXPRESSION TREE




Amir Barylko                    Advanced Design Patterns
EXPRESSION VISITOR




Amir Barylko                   Advanced Design Patterns
AND EXPR EVALUATION




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
class ProjectListPage
       include PageObject

         def navigate
           visit('/projects')
           self
         end

         def edit(project)
           row = find(:xpath, "//td[.='#{project.name}']")
           row.parent.click_link('Edit')
           ProjectEditPage.new
         end

         def projects
           all(:css, "#projects tr")......
         end
   end



Amir Barylko                                     Advanced Design Patterns
When /^I go to the projects page$/ do
       project_list_page.navigate
     end

     When /^I activate the project$/ do
       project_list_page.
         navigate.
         edit(current_project).
         activate.
         save
     end




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       4, 10-11 & 16-17

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

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



Amir Barylko                                       Advanced Design Patterns

Mais conteúdo relacionado

Mais procurados

2012 regina TC - 103 quality driven
2012 regina TC - 103 quality driven2012 regina TC - 103 quality driven
2012 regina TC - 103 quality drivenAmir Barylko
 
Agile requirements
Agile requirementsAgile requirements
Agile requirementsAmir Barylko
 
Making the Switch: One Team's Story of Adopting JIRA, FishEye, Eclipse & Myly...
Making the Switch: One Team's Story of Adopting JIRA, FishEye, Eclipse & Myly...Making the Switch: One Team's Story of Adopting JIRA, FishEye, Eclipse & Myly...
Making the Switch: One Team's Story of Adopting JIRA, FishEye, Eclipse & Myly...Atlassian
 
Photographic Film and Slide Scanning Alternatives
Photographic Film and Slide Scanning AlternativesPhotographic Film and Slide Scanning Alternatives
Photographic Film and Slide Scanning Alternativesmdruziak
 
Android java fx-jme@jug-lugano
Android java fx-jme@jug-luganoAndroid java fx-jme@jug-lugano
Android java fx-jme@jug-luganoFabrizio Giudici
 
Deep Dive into Flex Mobile Item Renderers
Deep Dive into Flex Mobile Item RenderersDeep Dive into Flex Mobile Item Renderers
Deep Dive into Flex Mobile Item RenderersJason Hanson
 
iCharge & iStand
iCharge & iStandiCharge & iStand
iCharge & iStanddearluci
 
PMI-ACP Lesson 2 : Scrum
PMI-ACP Lesson 2 : ScrumPMI-ACP Lesson 2 : Scrum
PMI-ACP Lesson 2 : ScrumSaket Bansal
 
Aft 157 design process project -ii
Aft 157 design process project -iiAft 157 design process project -ii
Aft 157 design process project -iiKrishn Verma
 
Arbyte - A modular, flexible, scalable job queing and execution system
Arbyte - A modular, flexible, scalable job queing and execution systemArbyte - A modular, flexible, scalable job queing and execution system
Arbyte - A modular, flexible, scalable job queing and execution systemlokku
 

Mais procurados (11)

2012 regina TC - 103 quality driven
2012 regina TC - 103 quality driven2012 regina TC - 103 quality driven
2012 regina TC - 103 quality driven
 
Agile requirements
Agile requirementsAgile requirements
Agile requirements
 
Making the Switch: One Team's Story of Adopting JIRA, FishEye, Eclipse & Myly...
Making the Switch: One Team's Story of Adopting JIRA, FishEye, Eclipse & Myly...Making the Switch: One Team's Story of Adopting JIRA, FishEye, Eclipse & Myly...
Making the Switch: One Team's Story of Adopting JIRA, FishEye, Eclipse & Myly...
 
Photographic Film and Slide Scanning Alternatives
Photographic Film and Slide Scanning AlternativesPhotographic Film and Slide Scanning Alternatives
Photographic Film and Slide Scanning Alternatives
 
Android java fx-jme@jug-lugano
Android java fx-jme@jug-luganoAndroid java fx-jme@jug-lugano
Android java fx-jme@jug-lugano
 
Deep Dive into Flex Mobile Item Renderers
Deep Dive into Flex Mobile Item RenderersDeep Dive into Flex Mobile Item Renderers
Deep Dive into Flex Mobile Item Renderers
 
iCharge & iStand
iCharge & iStandiCharge & iStand
iCharge & iStand
 
PMI-ACP Lesson 2 : Scrum
PMI-ACP Lesson 2 : ScrumPMI-ACP Lesson 2 : Scrum
PMI-ACP Lesson 2 : Scrum
 
Writing Storyboards
Writing StoryboardsWriting Storyboards
Writing Storyboards
 
Aft 157 design process project -ii
Aft 157 design process project -iiAft 157 design process project -ii
Aft 157 design process project -ii
 
Arbyte - A modular, flexible, scalable job queing and execution system
Arbyte - A modular, flexible, scalable job queing and execution systemArbyte - A modular, flexible, scalable job queing and execution system
Arbyte - A modular, flexible, scalable job queing and execution system
 

Destaque

Recommendation System for Design Patterns in Software Development
Recommendation System for Design Patterns in Software DevelopmentRecommendation System for Design Patterns in Software Development
Recommendation System for Design Patterns in Software DevelopmentFrancis Palma
 
Unity - Software Design Patterns
Unity - Software Design PatternsUnity - Software Design Patterns
Unity - Software Design PatternsDavid Baron
 
Implementing advanced integration patterns with WSO2 ESB
Implementing advanced integration patterns with WSO2 ESBImplementing advanced integration patterns with WSO2 ESB
Implementing advanced integration patterns with WSO2 ESBWSO2
 
Software Design Patterns in Practice
Software Design Patterns in PracticeSoftware Design Patterns in Practice
Software Design Patterns in PracticePtidej Team
 
Advanced Patterns with io.ReadWriter
Advanced Patterns with io.ReadWriterAdvanced Patterns with io.ReadWriter
Advanced Patterns with io.ReadWriterWeaveworks
 
Software design patterns ppt
Software design patterns pptSoftware design patterns ppt
Software design patterns pptmkruthika
 

Destaque (9)

Recommendation System for Design Patterns in Software Development
Recommendation System for Design Patterns in Software DevelopmentRecommendation System for Design Patterns in Software Development
Recommendation System for Design Patterns in Software Development
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Unity - Software Design Patterns
Unity - Software Design PatternsUnity - Software Design Patterns
Unity - Software Design Patterns
 
Implementing advanced integration patterns with WSO2 ESB
Implementing advanced integration patterns with WSO2 ESBImplementing advanced integration patterns with WSO2 ESB
Implementing advanced integration patterns with WSO2 ESB
 
Software Design Patterns in Practice
Software Design Patterns in PracticeSoftware Design Patterns in Practice
Software Design Patterns in Practice
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Advanced Patterns with io.ReadWriter
Advanced Patterns with io.ReadWriterAdvanced Patterns with io.ReadWriter
Advanced Patterns with io.ReadWriter
 
Software design patterns ppt
Software design patterns pptSoftware design patterns ppt
Software design patterns ppt
 

Semelhante a PRDCW-advanced-design-patterns

Code camp 2012-advanced-design-patterns
Code camp 2012-advanced-design-patternsCode camp 2012-advanced-design-patterns
Code camp 2012-advanced-design-patternsAmir Barylko
 
sdec11-Advanced-design-patterns
sdec11-Advanced-design-patternssdec11-Advanced-design-patterns
sdec11-Advanced-design-patternsAmir Barylko
 
DevTeach12-Capybara
DevTeach12-CapybaraDevTeach12-Capybara
DevTeach12-CapybaraAmir Barylko
 
DevTeach12-betterspecs
DevTeach12-betterspecsDevTeach12-betterspecs
DevTeach12-betterspecsAmir Barylko
 
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
 
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
 
DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻都元ダイスケ Miyamoto
 
Beutiful javascript with coffeescript
Beutiful javascript with coffeescriptBeutiful javascript with coffeescript
Beutiful javascript with coffeescriptAmir Barylko
 
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
 
Page objects pattern
Page objects patternPage objects pattern
Page objects patternAmir Barylko
 
Page-objects-pattern
Page-objects-patternPage-objects-pattern
Page-objects-patternAmir 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
 
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
 
SDEC12 Beautiful javascript with coffeescript
SDEC12 Beautiful javascript with coffeescriptSDEC12 Beautiful javascript with coffeescript
SDEC12 Beautiful javascript with coffeescriptAmir Barylko
 

Semelhante a PRDCW-advanced-design-patterns (20)

Code camp 2012-advanced-design-patterns
Code camp 2012-advanced-design-patternsCode camp 2012-advanced-design-patterns
Code camp 2012-advanced-design-patterns
 
sdec11-Advanced-design-patterns
sdec11-Advanced-design-patternssdec11-Advanced-design-patterns
sdec11-Advanced-design-patterns
 
DevTeach12-Capybara
DevTeach12-CapybaraDevTeach12-Capybara
DevTeach12-Capybara
 
DevTeach12-betterspecs
DevTeach12-betterspecsDevTeach12-betterspecs
DevTeach12-betterspecs
 
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
 
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
 
DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻
 
Beutiful javascript with coffeescript
Beutiful javascript with coffeescriptBeutiful javascript with coffeescript
Beutiful javascript with coffeescript
 
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
 
Page objects pattern
Page objects patternPage objects pattern
Page objects pattern
 
Page-objects-pattern
Page-objects-patternPage-objects-pattern
Page-objects-pattern
 
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
 
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
 
YEG-UG-Capybara
YEG-UG-CapybaraYEG-UG-Capybara
YEG-UG-Capybara
 
SDEC12 Beautiful javascript with coffeescript
SDEC12 Beautiful javascript with coffeescriptSDEC12 Beautiful javascript with coffeescript
SDEC12 Beautiful javascript with coffeescript
 

Mais 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 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
 
Cpl12 continuous integration
Cpl12 continuous integrationCpl12 continuous integration
Cpl12 continuous integrationAmir Barylko
 
Awesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAwesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAmir Barylko
 

Mais 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 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
 
Cpl12 continuous integration
Cpl12 continuous integrationCpl12 continuous integration
Cpl12 continuous integration
 
Awesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAwesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescript
 

Último

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
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
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
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
 
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
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Último (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
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
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
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?
 
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
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

PRDCW-advanced-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 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. 18 • Event Sourcing • Null Object 22 • Proxy 1 • Factory 4 • List • ActiveRecord 12 Comprehension • Strategy 11 1 • Repository 5 • DTO 4 • Object Mother10 • Event Aggregator • Page Object 16 26 • Visitor 8 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. SnapToX Next SnapToY SnapToPrevious Next Amir Barylko Advanced Design Patterns
  • 13. Amir Barylko Advanced Design Patterns
  • 14. 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
  • 15. GOF Amir Barylko Advanced Design Patterns
  • 16. PROXY SEQUENCE Amir Barylko Advanced Design Patterns
  • 17. 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
  • 18. 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
  • 19. movie = Movie.new movie.all # all records # filter by title movie.where(title: 'Spaceballs') # finds by attribute movie.find_by_title('Blazing Saddles') # order, skip some and limit the result movie.order('title DESC').skip(2).limit(5) # associations CRUD movie.reviews.create(name: 'Jay Sherman', stars: 1, comment: 'It stinks!') Amir Barylko Advanced Design Patterns
  • 20. REPOSITORY • Mediator between domain and storage • Acts like a collection of items • Supports queries • Abstraction of the storage Amir Barylko Advanced Design Patterns
  • 21. Amir Barylko Advanced Design Patterns
  • 23. ANTIPATTERN CHEAPER BY THE DOZEN Amir Barylko Advanced Design Patterns
  • 24. WHAT TO DO? • Use a criteria or better a queryable result (LINQ) • Use a factory to return repositories • Use a UnitOfWork with a factory Amir Barylko Advanced Design Patterns
  • 25. 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
  • 26. 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
  • 27. MT COMMONS Amir Barylko Advanced Design Patterns
  • 28. COUPLED Amir Barylko Advanced Design Patterns
  • 29. DECOUPLED Amir Barylko Advanced Design Patterns
  • 30. 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
  • 32. Amir Barylko Advanced Design Patterns
  • 33. 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
  • 34. 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
  • 35. OBJECT MOTHER / BUILDER • Creates an object for testing (or other) purposes • Assumes defaults • Easy to configure • Fluent interface • Usually has methods to to easily manipulate the domain Amir Barylko Advanced Design Patterns
  • 36. 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
  • 37. Amir Barylko Advanced Design Patterns
  • 38. 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
  • 39. LINQ EXPRESSION TREE Amir Barylko Advanced Design Patterns
  • 40. EXPRESSION VISITOR Amir Barylko Advanced Design Patterns
  • 41. AND EXPR EVALUATION Amir Barylko Advanced Design Patterns
  • 42. NULL OBJECT • Represent “null” with an actual instance • Provides default functionality • Clear semantics of “null” for that domain Amir Barylko Advanced Design Patterns
  • 43. 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
  • 44. 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
  • 45. 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
  • 46. STRATEGY • Abstracts the algorithm to solve a particular problem • Can be configured dynamically • Are interchangeable Amir Barylko Advanced Design Patterns
  • 48. DATA TRANSFER OBJECT • Simplifies information transfer across services • Can be optimized • Easy to understand Amir Barylko Advanced Design Patterns
  • 50. 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
  • 51. class ProjectListPage include PageObject def navigate visit('/projects') self end def edit(project) row = find(:xpath, "//td[.='#{project.name}']") row.parent.click_link('Edit') ProjectEditPage.new end def projects all(:css, "#projects tr")...... end end Amir Barylko Advanced Design Patterns
  • 52. When /^I go to the projects page$/ do project_list_page.navigate end When /^I activate the project$/ do project_list_page. navigate. edit(current_project). activate. save end Amir Barylko Advanced Design Patterns
  • 53. QUESTIONS? Amir Barylko Advanced Design Patterns
  • 54. RESOURCES • Email: amir@barylko.com, @abarylko • Slides: http://www.orthocoders.com/presentations • Patterns: Each pattern example has a link Amir Barylko Advanced Design Patterns
  • 55. RESOURCES II Amir Barylko Advanced Design Patterns
  • 56. RESOURCES III Amir Barylko Advanced Design Patterns
  • 57. QUALITY SOFTWARE TRAINING • Topics: Kanban, BDD & TDD. • When: May 4, 10-11 & 16-17 • More info: http://www.maventhought.com • Goal: Learn techniques, methodologies and tools to improve the quality in your job. Amir Barylko Advanced Design Patterns