SlideShare a Scribd company logo
1 of 41
Download to read offline
Intentions & Interfaces
Making patterns concrete


Udi Dahan – The Software Simplist
.NET Development Expert & SOA Specialist

www.UdiDahan.com
email@UdiDahan.com
Books, and books, and books, and books…
Flexibility brings many benefits
Preventing rigidity from creeping in
Existing solutions

                     Strategy Pattern




 Visitor Pattern
Visitor pattern




            Requires a method for
            each ConcreteElement
Strategy pattern




                   Requires all classes to
                   contain a strategy
Application Code
May cause a collapse of
application structure
                               Infrastructure Code




              at          Co
                   ion          de
       lic

 App         Infrastructure Code
Doing too
much can hurt

 ou
  ren„t
  onna
  eed
 t
“Prediction is very
 difficult, especially if
 it's about the future.”



-- Niels Bohr
   Physics Nobel prize 1922
Bolt on flexibility where you need it
Sometimes called “hooks”


          Application Code



         Infrastructure Code




             New          New
             Code         Code
Flexibility you seek?

Hmm?

Made your roles
explicit, have you?

No?

That is why you fail.
Make
 Roles
  Explicit
Some well known interfaces

        ISerializable          IFather

                             IHusband
 Java   Serializable
                           IGoToWork

                          IComeHome

                        IWashTheDishes
Custom entity validation before persistence
The old “object-oriented” way
.Validate();              bool IsValidating;


      Customer         .Validate();
           *              Address

           .Validate();

       Order
                     But what if we start here?

       Persistence
It looks like our
objects have
too many roles
to play
Make roles explicit
Add a marker interface here,
and an interface there….
  IEntity
               where T : IEntity




                IValidator<T>
        ValidationError Validate(T entity);
The first part is trivial:
                                 IEntity




                      Customer


                        Order
The second part is more interesting
               IValidator<T>
      ValidationError Validate(T entity);




 Customer



  CustomerValidator:      IValidator<Customer>
   ValidationError Validate(Customer entity);
Add a dash of
Inversion of Control

Service-Locator style
The extensible way
 .Persist(Customer)
                          Persistence

 Service Locator   Get<IValidator<Customer>>
   new
                          Validate(Customer)

             Customer Validator
But that’s not
Object Oriented

Is it?
Extensible and Object Oriented
 .Persist(Customer)
                          Persistence

 Service Locator   Get<IValidator<Customer>>
   new                    Validate(Customer)
             Customer Validator

                         .Validate();

                           Customer
And application code stays simple
           Application Code


                     .Persist(Customer)


          Infrastructure Code
Loading objects from the DB
 public class Customer
 {
   public void MakePreferred()
   {
     foreach(Order o in this.UnshippedOrders)
       foreach(Orderline ol in o.OrderLines)
         ol.Discount(10.Percent);
   }
 }




 Lazy Loading
Dangers of Lazy Loading
 public void MakePreferred()
 {
   foreach(Order o in this.UnshippedOrders)
     foreach(Orderline ol in o.OrderLines)
       ol.Discount(10.Percent);
 }




                                  DB
Loading objects from the DB

 Making a customer
                        Adding an Order
    “preferred”

    Customer              Customer




                Order


OrderLine
Need Different “Fetching Strategies”
 public class ServiceLayer
 {
   public void MakePreferred(Id customerId)
   {
     Customer c = ORM.Get<Customer>(customerId);
     c.MakePreferred();
   }

  public void AddOrder(Id customerId, OrderInfo o)
   {
     Customer c = ORM.Get<Customer>(customerId);
     c.AddOrder(o);
   }
 }
Make
 Roles
  Explicit
Use interfaces to differentiate roles
 IMakeCustomerPreferred              IAddOrdersToCustomer
  void MakePreferred();               void AddOrder(Order o);




                          Customer
Application code specifies role
 public class ServiceLayer
 {
   public void MakePreferred(Id customerId)
   {
     IMakeCustomerPreferred c = ORM
        .Get< IMakeCustomerPreferred>(customerId);
     c.MakePreferred();
   }

  public void AddOrder(Id customerId, OrderInfo o)
   {
     IAddOrdersToCustomer c = ORM
         .Get< IAddOrdersToCustomer>(customerId);
     c.AddOrder(o);
   }
 }
Extend behavior around role
   IMakeCustomerPreferred                   IAddOrdersToCustomer
     void MakePreferred();                    void AddOrder(Order o);




                              Customer




           T
Inherits                     MakeCustomerPreferredFetchingStrategy :
                             IFetchingStrategy<IMakeCustomerPreferred>

                             string Strategy { get {
                              return “UnshippedOrders, OrderLines”; } }
IFetchingStrategy<T>
The extensible way
.Get<IMakeCustomerPreferred>(id)
                               Persistence

 Service Locator
    new    Get<IFetchingStrategy<
                IMakeCustomerPreferred>>

                                   Get strategy
              MakeCustomerPreferredFetchingStrategy
And the pattern repeats…


  IMessage
              where T : IEntity




             IMessageHandler<T>
             void Handle(T message);
Once your roles
made explicit,
you have…

Extensibility and
flexibility -
simple they will be
Thank you
 Udi Dahan – The Software Simplist
 .NET Development Expert & SOA Specialist

 www.UdiDahan.com
 email@UdiDahan.com

More Related Content

What's hot

Keep your code clean
Keep your code cleanKeep your code clean
Keep your code cleanmacrochen
 
Integrating FIDO & Federation Protocols
Integrating FIDO & Federation ProtocolsIntegrating FIDO & Federation Protocols
Integrating FIDO & Federation ProtocolsFIDO Alliance
 
最近のKeycloakのご紹介 ~クライアントポリシーとFAPI~
最近のKeycloakのご紹介 ~クライアントポリシーとFAPI~最近のKeycloakのご紹介 ~クライアントポリシーとFAPI~
最近のKeycloakのご紹介 ~クライアントポリシーとFAPI~Hitachi, Ltd. OSS Solution Center.
 
Hexagonal architecture: how, why and when
Hexagonal architecture: how, why and whenHexagonal architecture: how, why and when
Hexagonal architecture: how, why and whenXoubaman
 
Clean architecture
Clean architectureClean architecture
Clean architectureandbed
 
Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門Ryosuke Uchitate
 
知らなかった! Bitcoinとethereumの違い
知らなかった! Bitcoinとethereumの違い知らなかった! Bitcoinとethereumの違い
知らなかった! Bitcoinとethereumの違いShinji Ayanami
 
Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software designMatthias Noback
 
淺談RESTful API認證 Token機制使用經驗分享
淺談RESTful API認證 Token機制使用經驗分享淺談RESTful API認證 Token機制使用經驗分享
淺談RESTful API認證 Token機制使用經驗分享Tun-Yu Chang
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net coreSam Nasr, MCSA, MVP
 
Code Smells and Its type (With Example)
Code Smells and Its type (With Example)Code Smells and Its type (With Example)
Code Smells and Its type (With Example)Anshul Vinayak
 
良質なコードを高速に書くコツ
良質なコードを高速に書くコツ良質なコードを高速に書くコツ
良質なコードを高速に書くコツShunji Konishi
 
Dockerfile を書くためのベストプラクティス解説編
Dockerfile を書くためのベストプラクティス解説編Dockerfile を書くためのベストプラクティス解説編
Dockerfile を書くためのベストプラクティス解説編Masahito Zembutsu
 
Laravel Routing and Query Building
Laravel   Routing and Query BuildingLaravel   Routing and Query Building
Laravel Routing and Query BuildingMindfire Solutions
 
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!Ryosuke Uchitate
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerKoichi Sakata
 
Standards For Java Coding
Standards For Java CodingStandards For Java Coding
Standards For Java CodingRahul Bhutkar
 

What's hot (20)

Clean architecture
Clean architectureClean architecture
Clean architecture
 
Keep your code clean
Keep your code cleanKeep your code clean
Keep your code clean
 
Integrating FIDO & Federation Protocols
Integrating FIDO & Federation ProtocolsIntegrating FIDO & Federation Protocols
Integrating FIDO & Federation Protocols
 
最近のKeycloakのご紹介 ~クライアントポリシーとFAPI~
最近のKeycloakのご紹介 ~クライアントポリシーとFAPI~最近のKeycloakのご紹介 ~クライアントポリシーとFAPI~
最近のKeycloakのご紹介 ~クライアントポリシーとFAPI~
 
Hexagonal architecture: how, why and when
Hexagonal architecture: how, why and whenHexagonal architecture: how, why and when
Hexagonal architecture: how, why and when
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門
 
Laravel ppt
Laravel pptLaravel ppt
Laravel ppt
 
知らなかった! Bitcoinとethereumの違い
知らなかった! Bitcoinとethereumの違い知らなかった! Bitcoinとethereumの違い
知らなかった! Bitcoinとethereumの違い
 
Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software design
 
淺談RESTful API認證 Token機制使用經驗分享
淺談RESTful API認證 Token機制使用經驗分享淺談RESTful API認證 Token機制使用經驗分享
淺談RESTful API認證 Token機制使用經驗分享
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net core
 
Code Smells and Its type (With Example)
Code Smells and Its type (With Example)Code Smells and Its type (With Example)
Code Smells and Its type (With Example)
 
良質なコードを高速に書くコツ
良質なコードを高速に書くコツ良質なコードを高速に書くコツ
良質なコードを高速に書くコツ
 
Dockerfile を書くためのベストプラクティス解説編
Dockerfile を書くためのベストプラクティス解説編Dockerfile を書くためのベストプラクティス解説編
Dockerfile を書くためのベストプラクティス解説編
 
Laravel Routing and Query Building
Laravel   Routing and Query BuildingLaravel   Routing and Query Building
Laravel Routing and Query Building
 
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT Compiler
 
Standards For Java Coding
Standards For Java CodingStandards For Java Coding
Standards For Java Coding
 
Keycloak入門
Keycloak入門Keycloak入門
Keycloak入門
 

Viewers also liked

Aspect Orientated Programming in Ruby
Aspect Orientated Programming in RubyAspect Orientated Programming in Ruby
Aspect Orientated Programming in Rubydeimos
 
Felipe Rodrigues Ddd The Way Back To Oo
Felipe Rodrigues Ddd The Way Back To OoFelipe Rodrigues Ddd The Way Back To Oo
Felipe Rodrigues Ddd The Way Back To Oodeimos
 
Our way to microservices
Our way to microservicesOur way to microservices
Our way to microservicesAndi Pangeran
 
Modelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven DesignModelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven DesignNaeem Sarfraz
 
CQRS and Event Sourcing with MongoDB and PHP
CQRS and Event Sourcing with MongoDB and PHPCQRS and Event Sourcing with MongoDB and PHP
CQRS and Event Sourcing with MongoDB and PHPDavide Bellettini
 
Designing APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven DesignDesigning APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven DesignLaunchAny
 
Aslak Hellesoy Executable User Stories R Spec Bdd
Aslak Hellesoy Executable User Stories R Spec BddAslak Hellesoy Executable User Stories R Spec Bdd
Aslak Hellesoy Executable User Stories R Spec Bdddeimos
 
Great marketing can save the world
Great marketing can save the worldGreat marketing can save the world
Great marketing can save the worldIan Lurie
 
Putting 2.0 to Work for You
Putting 2.0 to Work for YouPutting 2.0 to Work for You
Putting 2.0 to Work for YouBobbi Newman
 
Media aan de Maas kickoff presentatie
Media aan de Maas kickoff presentatieMedia aan de Maas kickoff presentatie
Media aan de Maas kickoff presentatieAtticus
 
HAPILABS Media Kit
HAPILABS Media KitHAPILABS Media Kit
HAPILABS Media KitAnxa.com
 
#HBASummit 2014 - Metrics that Matter
#HBASummit 2014 - Metrics that Matter#HBASummit 2014 - Metrics that Matter
#HBASummit 2014 - Metrics that MatterMichael Street
 
Richtlijnen Schrijven Internetteksten Presentatie1
Richtlijnen Schrijven Internetteksten Presentatie1Richtlijnen Schrijven Internetteksten Presentatie1
Richtlijnen Schrijven Internetteksten Presentatie1UitinBrabant.nl
 
El Arte En Las Manos
El Arte En Las ManosEl Arte En Las Manos
El Arte En Las ManosDescojonate
 
The Pigman Vocabulary
The Pigman VocabularyThe Pigman Vocabulary
The Pigman Vocabularybarryrbarber
 
Fets amb massapà
Fets amb massapàFets amb massapà
Fets amb massapàguest85b218
 
2n111nabeelah
2n111nabeelah2n111nabeelah
2n111nabeelahnamirahbh
 

Viewers also liked (20)

Aspect Orientated Programming in Ruby
Aspect Orientated Programming in RubyAspect Orientated Programming in Ruby
Aspect Orientated Programming in Ruby
 
Felipe Rodrigues Ddd The Way Back To Oo
Felipe Rodrigues Ddd The Way Back To OoFelipe Rodrigues Ddd The Way Back To Oo
Felipe Rodrigues Ddd The Way Back To Oo
 
Our way to microservices
Our way to microservicesOur way to microservices
Our way to microservices
 
CQRS
CQRSCQRS
CQRS
 
Modelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven DesignModelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven Design
 
CQRS and Event Sourcing with MongoDB and PHP
CQRS and Event Sourcing with MongoDB and PHPCQRS and Event Sourcing with MongoDB and PHP
CQRS and Event Sourcing with MongoDB and PHP
 
Designing APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven DesignDesigning APIs and Microservices Using Domain-Driven Design
Designing APIs and Microservices Using Domain-Driven Design
 
Aslak Hellesoy Executable User Stories R Spec Bdd
Aslak Hellesoy Executable User Stories R Spec BddAslak Hellesoy Executable User Stories R Spec Bdd
Aslak Hellesoy Executable User Stories R Spec Bdd
 
Great marketing can save the world
Great marketing can save the worldGreat marketing can save the world
Great marketing can save the world
 
Klassika
KlassikaKlassika
Klassika
 
Putting 2.0 to Work for You
Putting 2.0 to Work for YouPutting 2.0 to Work for You
Putting 2.0 to Work for You
 
Media aan de Maas kickoff presentatie
Media aan de Maas kickoff presentatieMedia aan de Maas kickoff presentatie
Media aan de Maas kickoff presentatie
 
HAPILABS Media Kit
HAPILABS Media KitHAPILABS Media Kit
HAPILABS Media Kit
 
#HBASummit 2014 - Metrics that Matter
#HBASummit 2014 - Metrics that Matter#HBASummit 2014 - Metrics that Matter
#HBASummit 2014 - Metrics that Matter
 
Richtlijnen Schrijven Internetteksten Presentatie1
Richtlijnen Schrijven Internetteksten Presentatie1Richtlijnen Schrijven Internetteksten Presentatie1
Richtlijnen Schrijven Internetteksten Presentatie1
 
Banderas
BanderasBanderas
Banderas
 
El Arte En Las Manos
El Arte En Las ManosEl Arte En Las Manos
El Arte En Las Manos
 
The Pigman Vocabulary
The Pigman VocabularyThe Pigman Vocabulary
The Pigman Vocabulary
 
Fets amb massapà
Fets amb massapàFets amb massapà
Fets amb massapà
 
2n111nabeelah
2n111nabeelah2n111nabeelah
2n111nabeelah
 

Similar to Udi Dahan Intentions And Interfaces

14147503 Intentions Interfaces Making Patterns Concrete
14147503 Intentions Interfaces Making Patterns Concrete14147503 Intentions Interfaces Making Patterns Concrete
14147503 Intentions Interfaces Making Patterns ConcreteQConLondon2008
 
Entity Framework v2 Best Practices
Entity Framework v2 Best PracticesEntity Framework v2 Best Practices
Entity Framework v2 Best PracticesAndri Yadi
 
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...tdc-globalcode
 
Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01google
 
Entity framework db model的驗證機制 20130914
Entity framework db model的驗證機制 20130914Entity framework db model的驗證機制 20130914
Entity framework db model的驗證機制 20130914LearningTech
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2Hammad Rajjoub
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2Hammad Rajjoub
 
Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)Paulo Gandra de Sousa
 
Dev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming ManDev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming ManQuek Lilian
 
Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsSalesforce Developers
 
GraphQL - when REST API is not enough - lessons learned
GraphQL - when REST API is not enough - lessons learnedGraphQL - when REST API is not enough - lessons learned
GraphQL - when REST API is not enough - lessons learnedMarcinStachniuk
 
Dsug 05 02-15 - ScalDI - lightweight DI in Scala
Dsug 05 02-15 - ScalDI - lightweight DI in ScalaDsug 05 02-15 - ScalDI - lightweight DI in Scala
Dsug 05 02-15 - ScalDI - lightweight DI in ScalaUgo Matrangolo
 
Data validation infrastructure: the validate package
Data validation infrastructure: the validate packageData validation infrastructure: the validate package
Data validation infrastructure: the validate packageMark Van Der Loo
 
Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016Steven Smith
 

Similar to Udi Dahan Intentions And Interfaces (20)

14147503 Intentions Interfaces Making Patterns Concrete
14147503 Intentions Interfaces Making Patterns Concrete14147503 Intentions Interfaces Making Patterns Concrete
14147503 Intentions Interfaces Making Patterns Concrete
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 
Tdd,Ioc
Tdd,IocTdd,Ioc
Tdd,Ioc
 
Entity Framework v2 Best Practices
Entity Framework v2 Best PracticesEntity Framework v2 Best Practices
Entity Framework v2 Best Practices
 
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
 
CDI @javaonehyderabad
CDI @javaonehyderabadCDI @javaonehyderabad
CDI @javaonehyderabad
 
Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01
 
Entity framework db model的驗證機制 20130914
Entity framework db model的驗證機制 20130914Entity framework db model的驗證機制 20130914
Entity framework db model的驗證機制 20130914
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
 
PoEAA by Example
PoEAA by ExamplePoEAA by Example
PoEAA by Example
 
Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)
 
B_110500002
B_110500002B_110500002
B_110500002
 
Dev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming ManDev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming Man
 
Code contract
Code contractCode contract
Code contract
 
Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong Foundations
 
GraphQL - when REST API is not enough - lessons learned
GraphQL - when REST API is not enough - lessons learnedGraphQL - when REST API is not enough - lessons learned
GraphQL - when REST API is not enough - lessons learned
 
Dsug 05 02-15 - ScalDI - lightweight DI in Scala
Dsug 05 02-15 - ScalDI - lightweight DI in ScalaDsug 05 02-15 - ScalDI - lightweight DI in Scala
Dsug 05 02-15 - ScalDI - lightweight DI in Scala
 
Data validation infrastructure: the validate package
Data validation infrastructure: the validate packageData validation infrastructure: the validate package
Data validation infrastructure: the validate package
 
Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016
 

More from deimos

Randy Shoup eBays Architectural Principles
Randy Shoup eBays Architectural PrinciplesRandy Shoup eBays Architectural Principles
Randy Shoup eBays Architectural Principlesdeimos
 
Remy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQueryRemy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQuerydeimos
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvmdeimos
 
Joe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand DwrJoe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand Dwrdeimos
 
Venkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In GroovyVenkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In Groovydeimos
 
Venkat Subramaniam Blending Java With Dynamic Languages
Venkat Subramaniam Blending Java With Dynamic LanguagesVenkat Subramaniam Blending Java With Dynamic Languages
Venkat Subramaniam Blending Java With Dynamic Languagesdeimos
 
Tim Mackinnon Agile And Beyond
Tim Mackinnon Agile And BeyondTim Mackinnon Agile And Beyond
Tim Mackinnon Agile And Beyonddeimos
 
Steve Vinoski Rest And Reuse And Serendipity
Steve Vinoski Rest And Reuse And SerendipitySteve Vinoski Rest And Reuse And Serendipity
Steve Vinoski Rest And Reuse And Serendipitydeimos
 
Stefan Tilkov Soa Rest And The Web
Stefan Tilkov Soa Rest And The WebStefan Tilkov Soa Rest And The Web
Stefan Tilkov Soa Rest And The Webdeimos
 
Stefan Tilkov Pragmatic Intro To Rest
Stefan Tilkov Pragmatic Intro To RestStefan Tilkov Pragmatic Intro To Rest
Stefan Tilkov Pragmatic Intro To Restdeimos
 
Rod Johnson Cathedral
Rod Johnson CathedralRod Johnson Cathedral
Rod Johnson Cathedraldeimos
 
Mike Stolz Dramatic Scalability
Mike Stolz Dramatic ScalabilityMike Stolz Dramatic Scalability
Mike Stolz Dramatic Scalabilitydeimos
 
Matt Youill Betfair
Matt Youill BetfairMatt Youill Betfair
Matt Youill Betfairdeimos
 
Pete Goodliffe A Tale Of Two Systems
Pete Goodliffe A Tale Of Two SystemsPete Goodliffe A Tale Of Two Systems
Pete Goodliffe A Tale Of Two Systemsdeimos
 
Paul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA RegistryPaul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA Registrydeimos
 
Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platformdeimos
 
Neal Gafter Java Evolution
Neal Gafter Java EvolutionNeal Gafter Java Evolution
Neal Gafter Java Evolutiondeimos
 
Markus Voelter Textual DSLs
Markus Voelter Textual DSLsMarkus Voelter Textual DSLs
Markus Voelter Textual DSLsdeimos
 
Marc Evers People Vs Process Beyond Agile
Marc Evers People Vs Process Beyond AgileMarc Evers People Vs Process Beyond Agile
Marc Evers People Vs Process Beyond Agiledeimos
 
Magnus Christerson Henk Kolk Domain Expert DSLs
Magnus Christerson Henk Kolk Domain Expert DSLsMagnus Christerson Henk Kolk Domain Expert DSLs
Magnus Christerson Henk Kolk Domain Expert DSLsdeimos
 

More from deimos (20)

Randy Shoup eBays Architectural Principles
Randy Shoup eBays Architectural PrinciplesRandy Shoup eBays Architectural Principles
Randy Shoup eBays Architectural Principles
 
Remy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQueryRemy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQuery
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvm
 
Joe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand DwrJoe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand Dwr
 
Venkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In GroovyVenkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In Groovy
 
Venkat Subramaniam Blending Java With Dynamic Languages
Venkat Subramaniam Blending Java With Dynamic LanguagesVenkat Subramaniam Blending Java With Dynamic Languages
Venkat Subramaniam Blending Java With Dynamic Languages
 
Tim Mackinnon Agile And Beyond
Tim Mackinnon Agile And BeyondTim Mackinnon Agile And Beyond
Tim Mackinnon Agile And Beyond
 
Steve Vinoski Rest And Reuse And Serendipity
Steve Vinoski Rest And Reuse And SerendipitySteve Vinoski Rest And Reuse And Serendipity
Steve Vinoski Rest And Reuse And Serendipity
 
Stefan Tilkov Soa Rest And The Web
Stefan Tilkov Soa Rest And The WebStefan Tilkov Soa Rest And The Web
Stefan Tilkov Soa Rest And The Web
 
Stefan Tilkov Pragmatic Intro To Rest
Stefan Tilkov Pragmatic Intro To RestStefan Tilkov Pragmatic Intro To Rest
Stefan Tilkov Pragmatic Intro To Rest
 
Rod Johnson Cathedral
Rod Johnson CathedralRod Johnson Cathedral
Rod Johnson Cathedral
 
Mike Stolz Dramatic Scalability
Mike Stolz Dramatic ScalabilityMike Stolz Dramatic Scalability
Mike Stolz Dramatic Scalability
 
Matt Youill Betfair
Matt Youill BetfairMatt Youill Betfair
Matt Youill Betfair
 
Pete Goodliffe A Tale Of Two Systems
Pete Goodliffe A Tale Of Two SystemsPete Goodliffe A Tale Of Two Systems
Pete Goodliffe A Tale Of Two Systems
 
Paul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA RegistryPaul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA Registry
 
Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platform
 
Neal Gafter Java Evolution
Neal Gafter Java EvolutionNeal Gafter Java Evolution
Neal Gafter Java Evolution
 
Markus Voelter Textual DSLs
Markus Voelter Textual DSLsMarkus Voelter Textual DSLs
Markus Voelter Textual DSLs
 
Marc Evers People Vs Process Beyond Agile
Marc Evers People Vs Process Beyond AgileMarc Evers People Vs Process Beyond Agile
Marc Evers People Vs Process Beyond Agile
 
Magnus Christerson Henk Kolk Domain Expert DSLs
Magnus Christerson Henk Kolk Domain Expert DSLsMagnus Christerson Henk Kolk Domain Expert DSLs
Magnus Christerson Henk Kolk Domain Expert DSLs
 

Recently uploaded

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
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
 

Recently uploaded (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 

Udi Dahan Intentions And Interfaces

  • 1. Intentions & Interfaces Making patterns concrete Udi Dahan – The Software Simplist .NET Development Expert & SOA Specialist www.UdiDahan.com email@UdiDahan.com
  • 2. Books, and books, and books, and books…
  • 5. Existing solutions Strategy Pattern Visitor Pattern
  • 6. Visitor pattern Requires a method for each ConcreteElement
  • 7. Strategy pattern Requires all classes to contain a strategy
  • 8. Application Code May cause a collapse of application structure Infrastructure Code at Co ion de lic App Infrastructure Code
  • 9. Doing too much can hurt ou ren„t onna eed t
  • 10. “Prediction is very difficult, especially if it's about the future.” -- Niels Bohr Physics Nobel prize 1922
  • 11. Bolt on flexibility where you need it
  • 12. Sometimes called “hooks” Application Code Infrastructure Code New New Code Code
  • 13. Flexibility you seek? Hmm? Made your roles explicit, have you? No? That is why you fail.
  • 14. Make Roles Explicit
  • 15. Some well known interfaces ISerializable IFather IHusband Java Serializable IGoToWork IComeHome IWashTheDishes
  • 16.
  • 17.
  • 18. Custom entity validation before persistence
  • 19. The old “object-oriented” way .Validate(); bool IsValidating; Customer .Validate(); * Address .Validate(); Order But what if we start here? Persistence
  • 20. It looks like our objects have too many roles to play
  • 22. Add a marker interface here, and an interface there…. IEntity where T : IEntity IValidator<T> ValidationError Validate(T entity);
  • 23. The first part is trivial: IEntity Customer Order
  • 24. The second part is more interesting IValidator<T> ValidationError Validate(T entity); Customer CustomerValidator: IValidator<Customer> ValidationError Validate(Customer entity);
  • 25. Add a dash of Inversion of Control Service-Locator style
  • 26. The extensible way .Persist(Customer) Persistence Service Locator Get<IValidator<Customer>> new Validate(Customer) Customer Validator
  • 27. But that’s not Object Oriented Is it?
  • 28. Extensible and Object Oriented .Persist(Customer) Persistence Service Locator Get<IValidator<Customer>> new Validate(Customer) Customer Validator .Validate(); Customer
  • 29. And application code stays simple Application Code .Persist(Customer) Infrastructure Code
  • 30. Loading objects from the DB public class Customer { public void MakePreferred() { foreach(Order o in this.UnshippedOrders) foreach(Orderline ol in o.OrderLines) ol.Discount(10.Percent); } } Lazy Loading
  • 31. Dangers of Lazy Loading public void MakePreferred() { foreach(Order o in this.UnshippedOrders) foreach(Orderline ol in o.OrderLines) ol.Discount(10.Percent); } DB
  • 32. Loading objects from the DB Making a customer Adding an Order “preferred” Customer Customer Order OrderLine
  • 33. Need Different “Fetching Strategies” public class ServiceLayer { public void MakePreferred(Id customerId) { Customer c = ORM.Get<Customer>(customerId); c.MakePreferred(); } public void AddOrder(Id customerId, OrderInfo o) { Customer c = ORM.Get<Customer>(customerId); c.AddOrder(o); } }
  • 34. Make Roles Explicit
  • 35. Use interfaces to differentiate roles IMakeCustomerPreferred IAddOrdersToCustomer void MakePreferred(); void AddOrder(Order o); Customer
  • 36. Application code specifies role public class ServiceLayer { public void MakePreferred(Id customerId) { IMakeCustomerPreferred c = ORM .Get< IMakeCustomerPreferred>(customerId); c.MakePreferred(); } public void AddOrder(Id customerId, OrderInfo o) { IAddOrdersToCustomer c = ORM .Get< IAddOrdersToCustomer>(customerId); c.AddOrder(o); } }
  • 37. Extend behavior around role IMakeCustomerPreferred IAddOrdersToCustomer void MakePreferred(); void AddOrder(Order o); Customer T Inherits MakeCustomerPreferredFetchingStrategy : IFetchingStrategy<IMakeCustomerPreferred> string Strategy { get { return “UnshippedOrders, OrderLines”; } } IFetchingStrategy<T>
  • 38. The extensible way .Get<IMakeCustomerPreferred>(id) Persistence Service Locator new Get<IFetchingStrategy< IMakeCustomerPreferred>> Get strategy MakeCustomerPreferredFetchingStrategy
  • 39. And the pattern repeats… IMessage where T : IEntity IMessageHandler<T> void Handle(T message);
  • 40. Once your roles made explicit, you have… Extensibility and flexibility - simple they will be
  • 41. Thank you Udi Dahan – The Software Simplist .NET Development Expert & SOA Specialist www.UdiDahan.com email@UdiDahan.com