AMIR BARYLKO   DECOUPLING    WITH THEEVENT AGGREGATOR
WHO AM I?  • Quality      Expert  • Architect  • Developer  • Mentor  • Great      cook  • The     one who’s entertaining ...
RESOURCES  • Email: amir@barylko.com  • Twitter: @abarylko  • Blog: http://www.orthocoders.com  • Materials: http://www.or...
INTRO                                       Coupling                                       Cohesion                       ...
COUPLING & COHESIONAmir Barylko - Event Aggregator   MavenThought Inc.
COUPLING                                   (WIKIPEDIA)  Degree to which  each program module relies  on each one          ...
COUPLING II  Is usually contrasted                   with cohesionAmir Barylko - Event Aggregator                 MavenTho...
COUPLING III  Invented by Larry Constantine,  an original developer of             Structured DesignAmir Barylko - Event A...
COUPLING IV  Low coupling is often a  sign of a well-structured  computer system and a                    good designAmir ...
COUPLING V  When combined with  high cohesion,  supports high                readability and                maintainabilit...
COHESION                                   (WIKIPEDIA)  measure of how  strongly-related the  functionality expressed by t...
IS ALL ABOUT                          DEPENDENCIESAmir Barylko - Event Aggregator           MavenThought Inc.
HARDCODED                          DEPENDENCIES  public MovieLibrary()  {      this._storage = new LocalStorage();        ...
EXTRACT INTERFACES  private JaySherman _critic;  private IMDBPosterService _posterService;  private LocalStorage _storage;...
DEPENDENCY INJECTION  public MovieLibrary(IMovieStorage storage,                                  IMovieCritic critic,    ...
INVERSION OF CONTROLAmir Barylko - Event Aggregator   MavenThought Inc.
POOR’S MAN DI  public MovieLibrary()  {         this._storage = new LocalStorage();         this._critic = new JaySherman(...
USING IOC CONTAINER      Container.Register(        Component            .For<IMovieCritic>()            .ImplementedBy<Ja...
REFACTORING                                    What’s wrong?                                  Event Aggregator            ...
WHAT’S WRONG?Amir Barylko - Event Aggregator       MavenThought Inc.
TOO MANY DEPENDENCIESAmir Barylko - Event Aggregator   MavenThought Inc.
LET’S THINK  • Why the critic has to know the library (or      viceversa)?  • Or the poster service?  • If I need more ser...
DECENTRALIZE  • Identify boundaries  • Identify clear responsibilities  • Reduce complexity  • Find notification mechanismA...
WHAT I’D LIKE                                         Reviews             Library              ????                       ...
EVENT AGGREGATORAmir Barylko - Event Aggregator   MavenThought Inc.
THE PATTERN     Channel events     from multiple     objects into a     single object to     s i m p l i f y     registrat...
TRAITS  • Based        on subject - observer  • Centralize            event registration logic  • No       need to track m...
IMPLEMENTATIONAmir Barylko - Event Aggregator        MavenThought Inc.
WHAT WE NEED  •Register                   events  •Raise              events  •Subscribe                      to eventsAmi...
ATTEMPT #1Amir Barylko - Event Aggregator                MavenThought Inc.
ATTEMPT #2Amir Barylko - Event Aggregator                MavenThought Inc.
WHAT?             NO CONCRETE EVENT?  • How      can we get a concrete from an interface?  • Castle     Dynamic Proxy!  •I...
RAISING AN EVENTAmir Barylko - Event Aggregator        MavenThought Inc.
HOW TO USE IT                   if( !everybody.Asleep() )                   {                       Demo();               ...
WHAT’S NEXT?  •When                a movie is added     •Show              notification     •Show              posters     ...
SUMMARYAmir Barylko - Event Aggregator             MavenThought Inc.
TO FINALIZE  • Why  EA reduces                     • How would it work with     complexity?                         web ap...
RESOURCES  • Email: amir@barylko.com  • Twitter: @abarylko  • Slides    and code: http://bit.ly/orthoslidesAmir Barylko - ...
RESOURCES II  •Coupling: http://bit.ly/yo5AK7  •Event Aggregator: http://bit.ly/zL1LrG  •MavenThought Commons: http://bit....
SOFTWARE QUALITY                    WORKSHOP  • When: May            4, 10-11, 16-17  • More      info: http://www.maventh...
Upcoming SlideShare
Loading in...5
×

PRDCW-avent-aggregator

307

Published on

Presentation done at PRDC West about the Event Aggregator pattern

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
307
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "PRDCW-avent-aggregator"

  1. 1. AMIR BARYLKO DECOUPLING WITH THEEVENT AGGREGATOR
  2. 2. WHO AM I? • Quality Expert • Architect • Developer • Mentor • Great cook • The one who’s entertaining you for the next hour!Amir Barylko - Event Aggregator MavenThought Inc.
  3. 3. RESOURCES • Email: amir@barylko.com • Twitter: @abarylko • Blog: http://www.orthocoders.com • Materials: http://www.orthocoders.com/presentationsAmir Barylko - Event Aggregator MavenThought Inc.
  4. 4. INTRO Coupling Cohesion Dependencies Dependency Injection IoC ContainersAmir Barylko - Event Aggregator MavenThought Inc.
  5. 5. COUPLING & COHESIONAmir Barylko - Event Aggregator MavenThought Inc.
  6. 6. COUPLING (WIKIPEDIA) Degree to which each program module relies on each one of the other modulesAmir Barylko - Event Aggregator MavenThought Inc.
  7. 7. COUPLING II Is usually contrasted with cohesionAmir Barylko - Event Aggregator MavenThought Inc.
  8. 8. COUPLING III Invented by Larry Constantine, an original developer of Structured DesignAmir Barylko - Event Aggregator MavenThought Inc.
  9. 9. COUPLING IV Low coupling is often a sign of a well-structured computer system and a good designAmir Barylko - Event Aggregator MavenThought Inc.
  10. 10. COUPLING V When combined with high cohesion, supports high readability and maintainabilityAmir Barylko - Event Aggregator MavenThought Inc.
  11. 11. COHESION (WIKIPEDIA) measure of how strongly-related the functionality expressed by the source code of a software module isAmir Barylko - Event Aggregator MavenThought Inc.
  12. 12. IS ALL ABOUT DEPENDENCIESAmir Barylko - Event Aggregator MavenThought Inc.
  13. 13. HARDCODED DEPENDENCIES public MovieLibrary() { this._storage = new LocalStorage(); this._critic = new JaySherman(); this._posterService = new IMDBPosterService(); } very hard to test and maintain!Amir Barylko - Event Aggregator MavenThought Inc.
  14. 14. EXTRACT INTERFACES private JaySherman _critic; private IMDBPosterService _posterService; private LocalStorage _storage; private IMovieCritic _critic; private IMoviePosterService _posterService; private IMovieStorage _storage;Amir Barylko - Event Aggregator MavenThought Inc.
  15. 15. DEPENDENCY INJECTION public MovieLibrary(IMovieStorage storage, IMovieCritic critic, IMoviePosterService posterService) { this._storage = storage; this._critic = critic; this._posterService = posterService; } Better for testing... but who is going to initialize them?Amir Barylko - Event Aggregator MavenThought Inc.
  16. 16. INVERSION OF CONTROLAmir Barylko - Event Aggregator MavenThought Inc.
  17. 17. POOR’S MAN DI public MovieLibrary() { this._storage = new LocalStorage(); this._critic = new JaySherman(); this._posterService = new IMDBPosterService(); } Still testeable... but smells!Amir Barylko - Event Aggregator MavenThought Inc.
  18. 18. USING IOC CONTAINER Container.Register( Component .For<IMovieCritic>() .ImplementedBy<JaySherman>(), Component .For<IMoviePosterService>() .ImplementedBy<IMDBPosterService>(), Component .For<IMovieStorage>() .ImplementedBy<LocalStorage>());Amir Barylko - Event Aggregator MavenThought Inc.
  19. 19. REFACTORING What’s wrong? Event Aggregator Demo Desktop &Web applicationsAmir Barylko - Event Aggregator MavenThought Inc.
  20. 20. WHAT’S WRONG?Amir Barylko - Event Aggregator MavenThought Inc.
  21. 21. TOO MANY DEPENDENCIESAmir Barylko - Event Aggregator MavenThought Inc.
  22. 22. LET’S THINK • Why the critic has to know the library (or viceversa)? • Or the poster service? • If I need more services, do I add more dependencies to the library?Amir Barylko - Event Aggregator MavenThought Inc.
  23. 23. DECENTRALIZE • Identify boundaries • Identify clear responsibilities • Reduce complexity • Find notification mechanismAmir Barylko - Event Aggregator MavenThought Inc.
  24. 24. WHAT I’D LIKE Reviews Library ???? PostersAmir Barylko - Event Aggregator MavenThought Inc.
  25. 25. EVENT AGGREGATORAmir Barylko - Event Aggregator MavenThought Inc.
  26. 26. THE PATTERN Channel events from multiple objects into a single object to s i m p l i f y registration for clientsAmir Barylko - Event Aggregator MavenThought Inc.
  27. 27. TRAITS • Based on subject - observer • Centralize event registration logic • No need to track multiple objects • Level of indirectionAmir Barylko - Event Aggregator MavenThought Inc.
  28. 28. IMPLEMENTATIONAmir Barylko - Event Aggregator MavenThought Inc.
  29. 29. WHAT WE NEED •Register events •Raise events •Subscribe to eventsAmir Barylko - Event Aggregator MavenThought Inc.
  30. 30. ATTEMPT #1Amir Barylko - Event Aggregator MavenThought Inc.
  31. 31. ATTEMPT #2Amir Barylko - Event Aggregator MavenThought Inc.
  32. 32. WHAT? NO CONCRETE EVENT? • How can we get a concrete from an interface? • Castle Dynamic Proxy! •I have an interface and get a Proxy to a stub • All properties are stubbed to be configured!Amir Barylko - Event Aggregator MavenThought Inc.
  33. 33. RAISING AN EVENTAmir Barylko - Event Aggregator MavenThought Inc.
  34. 34. HOW TO USE IT if( !everybody.Asleep() ) { Demo(); }Amir Barylko - Event Aggregator MavenThought Inc.
  35. 35. WHAT’S NEXT? •When a movie is added •Show notification •Show posters •Show reviewsAmir Barylko - Event Aggregator MavenThought Inc.
  36. 36. SUMMARYAmir Barylko - Event Aggregator MavenThought Inc.
  37. 37. TO FINALIZE • Why EA reduces • How would it work with complexity? web applications? • What’s the difference with • What about Event Sourcing? WeakReferences? • So, wouldthat mean we are • What about polymorphic doing CQRS? event handling?Amir Barylko - Event Aggregator MavenThought Inc.
  38. 38. RESOURCES • Email: amir@barylko.com • Twitter: @abarylko • Slides and code: http://bit.ly/orthoslidesAmir Barylko - Event Aggregator MavenThought Inc.
  39. 39. RESOURCES II •Coupling: http://bit.ly/yo5AK7 •Event Aggregator: http://bit.ly/zL1LrG •MavenThought Commons: http://bit.ly/mt_commons • Bootstrapper:http://bit.ly/xHNiKB • Windsor Container:http://bit.ly/AmodqG • Castle Dynamic Proxy: http://bit.ly/wihfidAmir Barylko - Event Aggregator MavenThought Inc.
  40. 40. SOFTWARE QUALITY WORKSHOP • When: May 4, 10-11, 16-17 • More info: http://www.maventhought.comAmir Barylko - Event Aggregator MavenThought Inc.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×