PRDCW-avent-aggregator
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

PRDCW-avent-aggregator

  • 499 views
Uploaded on

Presentation done at PRDC West about the Event Aggregator pattern

Presentation done at PRDC West about the Event Aggregator pattern

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
499
On Slideshare
499
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
2
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. AMIR BARYLKO DECOUPLING WITH THEEVENT AGGREGATOR
  • 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. RESOURCES • Email: amir@barylko.com • Twitter: @abarylko • Blog: http://www.orthocoders.com • Materials: http://www.orthocoders.com/presentationsAmir Barylko - Event Aggregator MavenThought Inc.
  • 4. INTRO Coupling Cohesion Dependencies Dependency Injection IoC ContainersAmir Barylko - Event Aggregator MavenThought Inc.
  • 5. COUPLING & COHESIONAmir Barylko - Event Aggregator MavenThought Inc.
  • 6. COUPLING (WIKIPEDIA) Degree to which each program module relies on each one of the other modulesAmir Barylko - Event Aggregator MavenThought Inc.
  • 7. COUPLING II Is usually contrasted with cohesionAmir Barylko - Event Aggregator MavenThought Inc.
  • 8. COUPLING III Invented by Larry Constantine, an original developer of Structured DesignAmir Barylko - Event Aggregator MavenThought Inc.
  • 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. COUPLING V When combined with high cohesion, supports high readability and maintainabilityAmir Barylko - Event Aggregator MavenThought Inc.
  • 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. IS ALL ABOUT DEPENDENCIESAmir Barylko - Event Aggregator MavenThought Inc.
  • 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. 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. 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. INVERSION OF CONTROLAmir Barylko - Event Aggregator MavenThought Inc.
  • 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. 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. REFACTORING What’s wrong? Event Aggregator Demo Desktop &Web applicationsAmir Barylko - Event Aggregator MavenThought Inc.
  • 20. WHAT’S WRONG?Amir Barylko - Event Aggregator MavenThought Inc.
  • 21. TOO MANY DEPENDENCIESAmir Barylko - Event Aggregator MavenThought Inc.
  • 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. DECENTRALIZE • Identify boundaries • Identify clear responsibilities • Reduce complexity • Find notification mechanismAmir Barylko - Event Aggregator MavenThought Inc.
  • 24. WHAT I’D LIKE Reviews Library ???? PostersAmir Barylko - Event Aggregator MavenThought Inc.
  • 25. EVENT AGGREGATORAmir Barylko - Event Aggregator MavenThought Inc.
  • 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. TRAITS • Based on subject - observer • Centralize event registration logic • No need to track multiple objects • Level of indirectionAmir Barylko - Event Aggregator MavenThought Inc.
  • 28. IMPLEMENTATIONAmir Barylko - Event Aggregator MavenThought Inc.
  • 29. WHAT WE NEED •Register events •Raise events •Subscribe to eventsAmir Barylko - Event Aggregator MavenThought Inc.
  • 30. ATTEMPT #1Amir Barylko - Event Aggregator MavenThought Inc.
  • 31. ATTEMPT #2Amir Barylko - Event Aggregator MavenThought Inc.
  • 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. RAISING AN EVENTAmir Barylko - Event Aggregator MavenThought Inc.
  • 34. HOW TO USE IT if( !everybody.Asleep() ) { Demo(); }Amir Barylko - Event Aggregator MavenThought Inc.
  • 35. WHAT’S NEXT? •When a movie is added •Show notification •Show posters •Show reviewsAmir Barylko - Event Aggregator MavenThought Inc.
  • 36. SUMMARYAmir Barylko - Event Aggregator MavenThought Inc.
  • 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. RESOURCES • Email: amir@barylko.com • Twitter: @abarylko • Slides and code: http://bit.ly/orthoslidesAmir Barylko - Event Aggregator MavenThought Inc.
  • 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. SOFTWARE QUALITY WORKSHOP • When: May 4, 10-11, 16-17 • More info: http://www.maventhought.comAmir Barylko - Event Aggregator MavenThought Inc.