SlideShare a Scribd company logo
1 of 65
Domain Driven Design &
Development with Spring Portfolio



            Srini Penchikala
       Ann Arbor Java User Group
           February 24, 2009
About the Speaker
• Enterprise Architect
• Writer: InfoQ, TSS, ONJava, DevX Java, java.net
• Speaker
• Detroit Java User Group Leader
• Using Java/JEE since 2000
• SOA/Web Services since 2006
• PowerPoint since September 2008


                                                    2
Presentation Goal




 “What” Domain Driven Design (DDD) is and “How”
 Spring Portfolio helps in implementing a DDD project



                                                        3
Format
    Interactive



    Demos



    Duration: ~45 minutes



    Q&A





                            4
Before we start…




• How many have heard of Domain Driven Design before?
• How many are currently using DDD?



                                                        5
Agenda
•   Domain Driven Design & Development
•   Spring Portfolio
•   Dependency Injection / AOP / Annotations
•   Spring Security (Demo)
•   Architecture Enforcement (Demo)
•   Code Generation (Demo)
•   Conclusions


                                               6
Agenda
•   Domain Driven Design & Development
•   Spring Portfolio
•   Dependency Injection / AOP / Annotations
•   Spring Security (Demo)
•   Architecture Enforcement (Demo)
•   Code Generation (Demo)
•   Conclusions


                                               7
Layered Architecture Diagram




                               8
Architecture Layers
    User Interface



    Application



    Domain



    Infrastructure





                      9
Domain Layer
    Represents concepts of business,


    information about business situation, and
    business rules.
    Maintains state reflecting the business


    situation.
    This layer is the heart of business


    software*.


                                                10
J2EE Architecture Model
                                      HTTP
   Application       Controller
                                      Session Management




                                      Transaction Management
                      Facade
                                      Caching




   Data Access   Data Access Object




   Persistence    Domain Object
                              *
                                                     Notes:
                                                     •     No real Domain Layer
                                                     •     Business Logic in Façade Layer  (Stateless
                                                           Session Beans  )
                                                     •     Direct Access to Data Access Objects
                                                           (CRUD logic is infrastructure not business
                                                                                                    )
                                                     •     *Domain objects are really Persistence
   Data Store                                              classes with getters
                                                                              /setters
                     Database                        •     Infrastructure concerns have overtaken/
                                                           overshadowed the domain concerns
                                                                                                        11
The Problem
    Architects/Developers are thinking only about



    infrastructure.
    Most of the development time is still spent on



    writing plumbing code instead of real business
    logic.
    We have lost real OOP





                                                    12
Domain Driven Architecture




                             13
Domain Driven Design &
Development




                         14
Domain Driven Design
What:
  Domain Driven Design (DDD) is about


  mapping business domain concepts into
  software artifacts.
Why:
  To create better software by focusing on a


  model of the domain rather than the
  technology.

                                               15
Domain Driven Design
    Is not a:



        new technology
    


        new framework
    


        JSR standard
    



    Is a:



        design pattern
    




                         16
Advantages
    Promotes high cohesion and low coupling


    in the application code
    Easy to test domain components



    Business (domain) logic is isolated from


    non-domain and infrastructure code
    Adding/changing services does not


    influence the domain or other services.


                                               17
Development Styles
    Transaction Script



    Table Module



    Domain Model





                         18
Development Styles
    A single instance that handles the
•

    business logic for all rows in a database
    table or view.




Choose the right style for the right application/service


Source: Patterns of Enterprise Application Architecture, Martin Fowler   19
DDD Manifesto
(Business) Domain             Infrastructure
    Domain State & Behavior       Persistence
                             



    Business Logic                Transaction Management
                             



    Business Rules                Remoting
                             



                                  Scheduling
                              




                                                           20
Domain Objects
    Domain objects are instances of real


    entities which hold any knowledge or
    activity of the business domain.




                                           21
Main Elements
    Entities



        Objects defined by their identity, which remains
    


        same throughout the life of software
    Value Objects



        Immutable objects that have no identity & are used
    


        to describe an attribute of another object.
    (Domain) Services



        Objects that have no state & only have a defined
    


        behavior that’s not part of any domain object.
                                                           22
Other Elements

    Module:



        A method of organizing related concepts and tasks
    


        in order to reduce complexity.
    Domain object Lifecycle is managed by:



        Aggregate
    


        Factory
    


        Repository
    




                                                        23
DDD Thought Process
    Start with domain entities and domain logic



        Basic domain-driven & object-oriented principles
    



    Mentally start without a quot;servicequot; layer



        See how far you can get
    


        Add service level as required
    



    You can refactor to DDD





Source: Domain Driven Design with AOP and DI, Presentation by
Ramnivas Laddad                                                 24
DDD Lifecycle Diagram




                        25
Agenda
•   Domain Driven Design & Development
•   Spring Portfolio
•   Dependency Injection / AOP / Annotations
•   Spring Security (Demo)
•   Architecture Enforcement (Demo)
•   Code Generation (Demo)
•   Conclusions


                                               26
Spring Framework
• Separation of concerns (business v.
  infrastructure)
• POJO Based Design
• Business domain first, infrastructure concerns
  second
• Agile Development and Testing



                                               27
Spring Philosophy




                    28
Spring Portfolio
    Spring Core



    Spring AOP



    Spring Security



    Spring MVC/Spring WebFlow





                                29
The Project
    Project Management



        Agile Methodology (SCRUM)
    


        Iterative Design, Development, Unit Testing and
    


        Refactoring.
    Architecture



        Focus on business domain & alignment with
    


        business model
        Isolation & Modularity
    


        Loosely coupled with other layers
    

                                                          30
        POJO programming model.
    
Agenda
•   Domain Driven Design & Development
•   Spring Portfolio
•   Dependency Injection / AOP / Annotations
•   Spring Security (Demo)
•   Architecture Enforcement (Demo)
•   Code Generation (Demo)
•   Conclusions


                                               31
Design Recipe
    Object Oriented Programming (OOP)



    Dependency Injection (DI)



    Aspect-oriented Programming (AOP)



    Annotations





                                        32
DDD with OOP Principles
   Domain Element           State/Behavior

Entity, Value Object,   State and Behavior
Aggregate
Data Transfer Object    State only

Service, Repository     Behavior only


                                             33
Dependency Injection
• Decouple and manage the dependencies of
  the components in the application
• DI Frameworks:
  • Spring
  • Google Guice
  • Pico Container



                                            34
DI Use Cases
    Service



        Domain Classes
    


        Transaction Manager
    


    Domain



        Data Access Object (DAO)
    


    DAO class



        Data Source
    


        JPA Entity Manager
    



                                   35
Domain Object DI
• @Configurable annotation




                             36
Aspect-oriented Programming
• Allows developers to add behavior to objects
  in a non-obtrusive manner through use of
  static and dynamic crosscutting.
• Main goal is to code cross-cutting concerns in
  separate modules and apply them in a
  declarative way.


                                               37
AOP Use Cases
    Framework Built-In Aspects


        Transaction Management
    


        Security
    




    Custom Aspects


        Profiling
    


        Caching
    


        Rules
    




                                 38
Annotations
• Added in Java SE 5.0 as Java Metadata
  facility (JSR 175).
• Provide a way to add metadata to program
  elements.
• Defined by nearly every recent JSR standard.
• Also include a mechanism for adding custom
  annotations to the Java code*.

                                             39
Annotations For Domain Elements
   Layer    Domain Element    Annotation
Domain
            Entity,          @Entity (JPA),
            Value Object     @Configurable
Domain      Repository       @Repository
Domain      Service          @Service
Application Controller       @Controller
All         All              @Component
                                           40
Custom Annotations Use Cases
• Caching
• Validation




                               41
Custom Annotations
• Implementation Options
  •   Reflection
  •   Annotation Processing Tool (APT)
  •   Byte-code Instrumentation (Javassist)
  •   Aspects/AOP (AspectJ and Spring AOP)




                                              42
Agenda
•   Domain Driven Design & Development
•   Spring Portfolio
•   Dependency Injection / AOP / Annotations
•   Spring Security (Demo)
•   Architecture Enforcement (Demo)
•   Code Generation (Demo)
•   Conclusions


                                               43
Domain Aspects
    Data Access



    Persistence



    Transaction Management



    Domain Security



    Business Operation Retry



    Caching





                               44
Persistence & Txn Management
    JDBC




    JPA w/ Hibernate, OpenJPA, EclipseLink



    (TopLink)
    Spring JPA Utils & Data Source DI




    Spring JTA Support



       –   Transactions are managed in Service classes
           using quot;@Transactionalquot; annotation

                                                     45
Spring Security
    Declarative Application Security support




    Fits in very well with Spring Framework



          Authentication
      


          Authorization
      


              URL level
          


              Domain Object
          


              Service Method
          




                                               46
DEMO




       47
Agenda
•   Domain Driven Design & Development
•   Spring Portfolio
•   Dependency Injection / AOP / Annotations
•   Spring Security (Demo)
•   Architecture Enforcement (Demo)
•   Code Generation (Demo)
•   Conclusions


                                               48
Architecture Enforcement
• Domain Driven Design Rules
• Enforcement using Aspects and AOP




                                      49
Rules – Compile Time
    Service classes should not depend on



    Application layer classes
    DAO classes should only be called from



    Domain classes




                                             50
DEMO




       51
Rules – Run Time
    Business operation retry




    Caching



        System Settings (using AOP)
    


        Application Variables/Business Data (using
    


        Annotations)




                                                     52
DEMO




       53
Agenda
•   Domain Driven Design & Development
•   Spring Portfolio
•   Dependency Injection / AOP / Annotations
•   Spring Security (Demo)
•   Architecture Enforcement (Demo)
•   Code Generation (Demo)
•   Conclusions


                                               54
Code Generation
Write:
     XSD
 


     Domain / Service
 


Code Generate:
     DAO interface and implementation
 


     Facade (EJB's & WebServices)
 


     DTO's
 


     Unit Tests (including test data)
 


     Spring configuration files
 

                                        55
Code Generation Tools
    openArchitectureWare (oAW)




    AndroMDA




    Aceleo Spring Module




    Skyway Builder





                                 56
DEMO




       57
Tools
    Spring for:



        Scheduling (Quartz)
    


        Configuration Management (Commons
    


        Configuration, JMX)
    Hibernate Tools (for DDL generation)




    Dozer (DO/DTO Assembly)





                                            58
DDD Lifecycle Diagram Revisited




                                  59
Agenda
•   Domain Driven Design & Development
•   Spring Portfolio
•   Dependency Injection / AOP / Annotations
•   Spring Security (Demo)
•   Architecture Enforcement (Demo)
•   Code Generation (Demo)
•   Conclusions


                                               60
Conclusions
• Domain First, Infrastructure Second
• Layered Architecture & Separation of Concerns
• Always keep the quot;contextquot; in mind
• Balance between the quot;rightquot; vs. the quot;right nowquot;
• Upcoming Java/JEE releases focus on development
  & deployment simplicity
• Spring 3.0, Java EE 6, JPA 2.0, EJB 3.1


                                                    61
References
• Domain Driven Design and Development In Practice
  (http://www.infoq.com/articles/ddd-in-practice)
• Domain-Driven Design Website
  (http://www.domaindrivendesign.org/)
• Domain-Driven Design by Eric Evans
• Applying Domain-Driven Design and Patterns, Jimmy
  Nilsson
• Patterns of Enterprise Application Architecture, Martin
  Fowler
• Can DDD be Adequately Implemented Without DI and
  AOP (http://www.infoq.com/news/2008/02/ddd-di-aop)
                                                            62
Contact Information
• Domain-Driven Design and Enterprise Architecture
  articles on InfoQ.
• InfoQ website (http://www.infoq.com)
• E-Mail: srinipenchikala@gmail.com
• Blog: http://srinip2007.blogspot.com




                                                     63
Q&A




      64
Thank You
• Thank you for your attention
• Feedback survey




                                 65

More Related Content

What's hot

Onion Architecture
Onion ArchitectureOnion Architecture
Onion Architecture
matthidinger
 
Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps
Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps
Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps
Eason Kuo
 

What's hot (20)

Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
 
Deep Dive into Amazon ECS & Fargate
Deep Dive into Amazon ECS & FargateDeep Dive into Amazon ECS & Fargate
Deep Dive into Amazon ECS & Fargate
 
Domain Driven Design(DDD) Presentation
Domain Driven Design(DDD) PresentationDomain Driven Design(DDD) Presentation
Domain Driven Design(DDD) Presentation
 
Comprehensive Terraform Training
Comprehensive Terraform TrainingComprehensive Terraform Training
Comprehensive Terraform Training
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 
Onion Architecture
Onion ArchitectureOnion Architecture
Onion Architecture
 
AWS CDK Introduction
AWS CDK IntroductionAWS CDK Introduction
AWS CDK Introduction
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
 
Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps
Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps
Implementing Domain-Driven Design (Study Group) Chapter 3 - Context Maps
 
Programming Infrastructure with AWS CDK
Programming Infrastructure with AWS CDKProgramming Infrastructure with AWS CDK
Programming Infrastructure with AWS CDK
 
Domain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroDomain Driven Design: Zero to Hero
Domain Driven Design: Zero to Hero
 
Why Microservice
Why Microservice Why Microservice
Why Microservice
 
API Platform and Symfony: a Framework for API-driven Projects
API Platform and Symfony: a Framework for API-driven ProjectsAPI Platform and Symfony: a Framework for API-driven Projects
API Platform and Symfony: a Framework for API-driven Projects
 
Spring Ldap
Spring LdapSpring Ldap
Spring Ldap
 

Viewers also liked

Homeschooling 5 años
Homeschooling 5 añosHomeschooling 5 años
Homeschooling 5 años
inmaculada1415
 
Domain Driven Design - DDDSydney 2011
Domain Driven Design - DDDSydney 2011Domain Driven Design - DDDSydney 2011
Domain Driven Design - DDDSydney 2011
thinkddd
 
Rp 6 session 2 naresh bhatia
Rp 6  session 2 naresh bhatiaRp 6  session 2 naresh bhatia
Rp 6 session 2 naresh bhatia
sapientindia
 
Erlang factory layered architecture - final
Erlang factory   layered architecture - finalErlang factory   layered architecture - final
Erlang factory layered architecture - final
Dennis Docter
 

Viewers also liked (20)

A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slides
 
Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Domain Driven Design Demonstrated
Domain Driven Design Demonstrated
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Agile Yaklaşımlar
Agile YaklaşımlarAgile Yaklaşımlar
Agile Yaklaşımlar
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 
Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven Design
 
Event storming recipes
Event storming recipesEvent storming recipes
Event storming recipes
 
Domain Driven Design using Laravel
Domain Driven Design using LaravelDomain Driven Design using Laravel
Domain Driven Design using Laravel
 
Common Mechanical Engineering Terms
Common Mechanical Engineering TermsCommon Mechanical Engineering Terms
Common Mechanical Engineering Terms
 
Homeschooling 5 años
Homeschooling 5 añosHomeschooling 5 años
Homeschooling 5 años
 
Hipster JS: Angular & Firebase (Tri-JS Meetup)
Hipster JS: Angular & Firebase (Tri-JS Meetup)Hipster JS: Angular & Firebase (Tri-JS Meetup)
Hipster JS: Angular & Firebase (Tri-JS Meetup)
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Domain Driven Design - DDDSydney 2011
Domain Driven Design - DDDSydney 2011Domain Driven Design - DDDSydney 2011
Domain Driven Design - DDDSydney 2011
 
Rp 6 session 2 naresh bhatia
Rp 6  session 2 naresh bhatiaRp 6  session 2 naresh bhatia
Rp 6 session 2 naresh bhatia
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup
Applying Domain-Driven Design to APIs and Microservices  - Austin API MeetupApplying Domain-Driven Design to APIs and Microservices  - Austin API Meetup
Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup
 
Singleton Object Management
Singleton Object ManagementSingleton Object Management
Singleton Object Management
 
Erlang factory layered architecture - final
Erlang factory   layered architecture - finalErlang factory   layered architecture - final
Erlang factory layered architecture - final
 
Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013
 
Unit 3 machines
Unit 3 machines Unit 3 machines
Unit 3 machines
 

Similar to Domain Driven Design Development Spring Portfolio

Aras ALM Workshop for PLM Configuration Management
Aras ALM Workshop for PLM Configuration ManagementAras ALM Workshop for PLM Configuration Management
Aras ALM Workshop for PLM Configuration Management
Aras
 
[DSBW Spring 2009] Unit 03: WebEng Process Models
[DSBW Spring 2009] Unit 03: WebEng Process Models[DSBW Spring 2009] Unit 03: WebEng Process Models
[DSBW Spring 2009] Unit 03: WebEng Process Models
Carles Farré
 
Model Driven Architecture (MDA): Motivations, Status & Future
Model Driven Architecture (MDA): Motivations, Status & FutureModel Driven Architecture (MDA): Motivations, Status & Future
Model Driven Architecture (MDA): Motivations, Status & Future
elliando dias
 
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
deimos
 
Aras Innovator PLM Deployment Methodology
Aras Innovator PLM Deployment MethodologyAras Innovator PLM Deployment Methodology
Aras Innovator PLM Deployment Methodology
Aras
 
Jee design patterns- Marek Strejczek - Rule Financial
Jee design patterns- Marek Strejczek - Rule FinancialJee design patterns- Marek Strejczek - Rule Financial
Jee design patterns- Marek Strejczek - Rule Financial
Rule_Financial
 

Similar to Domain Driven Design Development Spring Portfolio (20)

Aras ALM Workshop for PLM Configuration Management
Aras ALM Workshop for PLM Configuration ManagementAras ALM Workshop for PLM Configuration Management
Aras ALM Workshop for PLM Configuration Management
 
[DSBW Spring 2009] Unit 03: WebEng Process Models
[DSBW Spring 2009] Unit 03: WebEng Process Models[DSBW Spring 2009] Unit 03: WebEng Process Models
[DSBW Spring 2009] Unit 03: WebEng Process Models
 
From Requirements Management to Release with Git for Android System
From Requirements Management to Release with Git for Android System From Requirements Management to Release with Git for Android System
From Requirements Management to Release with Git for Android System
 
Zen and Enterprise Architecture
Zen and Enterprise ArchitectureZen and Enterprise Architecture
Zen and Enterprise Architecture
 
Are good SharePoint solutions only a myth?
Are good SharePoint solutions only a myth?Are good SharePoint solutions only a myth?
Are good SharePoint solutions only a myth?
 
Novidades natural e adabas
Novidades natural e adabasNovidades natural e adabas
Novidades natural e adabas
 
Segundo Semario de SharePoint en Mexico por Joel Oleson
Segundo Semario de SharePoint en Mexico por Joel OlesonSegundo Semario de SharePoint en Mexico por Joel Oleson
Segundo Semario de SharePoint en Mexico por Joel Oleson
 
Model Driven Architecture (MDA): Motivations, Status & Future
Model Driven Architecture (MDA): Motivations, Status & FutureModel Driven Architecture (MDA): Motivations, Status & Future
Model Driven Architecture (MDA): Motivations, Status & Future
 
Bynet2.3 Adobe Flex builder 4
Bynet2.3 Adobe Flex builder 4Bynet2.3 Adobe Flex builder 4
Bynet2.3 Adobe Flex builder 4
 
Best Practices Europe 10 Steps To Successful Deployments
Best Practices Europe 10 Steps To Successful DeploymentsBest Practices Europe 10 Steps To Successful Deployments
Best Practices Europe 10 Steps To Successful Deployments
 
Architecture Enforcement Aspects Itarc2009
Architecture Enforcement Aspects Itarc2009Architecture Enforcement Aspects Itarc2009
Architecture Enforcement Aspects Itarc2009
 
Architecture Enforcement Aspects Itarc2009
Architecture Enforcement Aspects Itarc2009Architecture Enforcement Aspects Itarc2009
Architecture Enforcement Aspects Itarc2009
 
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
 
App301 Implement a Data Access Layer with Ent Lib
App301 Implement a Data Access Layer with Ent LibApp301 Implement a Data Access Layer with Ent Lib
App301 Implement a Data Access Layer with Ent Lib
 
Aras Innovator PLM Deployment Methodology
Aras Innovator PLM Deployment MethodologyAras Innovator PLM Deployment Methodology
Aras Innovator PLM Deployment Methodology
 
Methodology
MethodologyMethodology
Methodology
 
Refactoring Ruby on Rails Applications
Refactoring Ruby on Rails ApplicationsRefactoring Ruby on Rails Applications
Refactoring Ruby on Rails Applications
 
Jee design patterns- Marek Strejczek - Rule Financial
Jee design patterns- Marek Strejczek - Rule FinancialJee design patterns- Marek Strejczek - Rule Financial
Jee design patterns- Marek Strejczek - Rule Financial
 
2009-dec-10 Architectuur en HL7
2009-dec-10 Architectuur en HL72009-dec-10 Architectuur en HL7
2009-dec-10 Architectuur en HL7
 
Standard Issue: Preparing for the Future of Data Management
Standard Issue: Preparing for the Future of Data ManagementStandard Issue: Preparing for the Future of Data Management
Standard Issue: Preparing for the Future of Data Management
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 

Domain Driven Design Development Spring Portfolio

  • 1. Domain Driven Design & Development with Spring Portfolio Srini Penchikala Ann Arbor Java User Group February 24, 2009
  • 2. About the Speaker • Enterprise Architect • Writer: InfoQ, TSS, ONJava, DevX Java, java.net • Speaker • Detroit Java User Group Leader • Using Java/JEE since 2000 • SOA/Web Services since 2006 • PowerPoint since September 2008 2
  • 3. Presentation Goal “What” Domain Driven Design (DDD) is and “How” Spring Portfolio helps in implementing a DDD project 3
  • 4. Format Interactive  Demos  Duration: ~45 minutes  Q&A  4
  • 5. Before we start… • How many have heard of Domain Driven Design before? • How many are currently using DDD? 5
  • 6. Agenda • Domain Driven Design & Development • Spring Portfolio • Dependency Injection / AOP / Annotations • Spring Security (Demo) • Architecture Enforcement (Demo) • Code Generation (Demo) • Conclusions 6
  • 7. Agenda • Domain Driven Design & Development • Spring Portfolio • Dependency Injection / AOP / Annotations • Spring Security (Demo) • Architecture Enforcement (Demo) • Code Generation (Demo) • Conclusions 7
  • 9. Architecture Layers User Interface  Application  Domain  Infrastructure  9
  • 10. Domain Layer Represents concepts of business,  information about business situation, and business rules. Maintains state reflecting the business  situation. This layer is the heart of business  software*. 10
  • 11. J2EE Architecture Model HTTP Application Controller Session Management Transaction Management Facade Caching Data Access Data Access Object Persistence Domain Object * Notes: • No real Domain Layer • Business Logic in Façade Layer (Stateless Session Beans ) • Direct Access to Data Access Objects (CRUD logic is infrastructure not business ) • *Domain objects are really Persistence Data Store classes with getters /setters Database • Infrastructure concerns have overtaken/ overshadowed the domain concerns 11
  • 12. The Problem Architects/Developers are thinking only about  infrastructure. Most of the development time is still spent on  writing plumbing code instead of real business logic. We have lost real OOP  12
  • 14. Domain Driven Design & Development 14
  • 15. Domain Driven Design What: Domain Driven Design (DDD) is about  mapping business domain concepts into software artifacts. Why: To create better software by focusing on a  model of the domain rather than the technology. 15
  • 16. Domain Driven Design Is not a:  new technology  new framework  JSR standard  Is a:  design pattern  16
  • 17. Advantages Promotes high cohesion and low coupling  in the application code Easy to test domain components  Business (domain) logic is isolated from  non-domain and infrastructure code Adding/changing services does not  influence the domain or other services. 17
  • 18. Development Styles Transaction Script  Table Module  Domain Model  18
  • 19. Development Styles A single instance that handles the • business logic for all rows in a database table or view. Choose the right style for the right application/service Source: Patterns of Enterprise Application Architecture, Martin Fowler 19
  • 20. DDD Manifesto (Business) Domain Infrastructure Domain State & Behavior Persistence   Business Logic Transaction Management   Business Rules Remoting   Scheduling  20
  • 21. Domain Objects Domain objects are instances of real  entities which hold any knowledge or activity of the business domain. 21
  • 22. Main Elements Entities  Objects defined by their identity, which remains  same throughout the life of software Value Objects  Immutable objects that have no identity & are used  to describe an attribute of another object. (Domain) Services  Objects that have no state & only have a defined  behavior that’s not part of any domain object. 22
  • 23. Other Elements Module:  A method of organizing related concepts and tasks  in order to reduce complexity. Domain object Lifecycle is managed by:  Aggregate  Factory  Repository  23
  • 24. DDD Thought Process Start with domain entities and domain logic  Basic domain-driven & object-oriented principles  Mentally start without a quot;servicequot; layer  See how far you can get  Add service level as required  You can refactor to DDD  Source: Domain Driven Design with AOP and DI, Presentation by Ramnivas Laddad 24
  • 26. Agenda • Domain Driven Design & Development • Spring Portfolio • Dependency Injection / AOP / Annotations • Spring Security (Demo) • Architecture Enforcement (Demo) • Code Generation (Demo) • Conclusions 26
  • 27. Spring Framework • Separation of concerns (business v. infrastructure) • POJO Based Design • Business domain first, infrastructure concerns second • Agile Development and Testing 27
  • 29. Spring Portfolio Spring Core  Spring AOP  Spring Security  Spring MVC/Spring WebFlow  29
  • 30. The Project Project Management  Agile Methodology (SCRUM)  Iterative Design, Development, Unit Testing and  Refactoring. Architecture  Focus on business domain & alignment with  business model Isolation & Modularity  Loosely coupled with other layers  30 POJO programming model. 
  • 31. Agenda • Domain Driven Design & Development • Spring Portfolio • Dependency Injection / AOP / Annotations • Spring Security (Demo) • Architecture Enforcement (Demo) • Code Generation (Demo) • Conclusions 31
  • 32. Design Recipe Object Oriented Programming (OOP)  Dependency Injection (DI)  Aspect-oriented Programming (AOP)  Annotations  32
  • 33. DDD with OOP Principles Domain Element State/Behavior Entity, Value Object, State and Behavior Aggregate Data Transfer Object State only Service, Repository Behavior only 33
  • 34. Dependency Injection • Decouple and manage the dependencies of the components in the application • DI Frameworks: • Spring • Google Guice • Pico Container 34
  • 35. DI Use Cases Service  Domain Classes  Transaction Manager  Domain  Data Access Object (DAO)  DAO class  Data Source  JPA Entity Manager  35
  • 36. Domain Object DI • @Configurable annotation 36
  • 37. Aspect-oriented Programming • Allows developers to add behavior to objects in a non-obtrusive manner through use of static and dynamic crosscutting. • Main goal is to code cross-cutting concerns in separate modules and apply them in a declarative way. 37
  • 38. AOP Use Cases Framework Built-In Aspects  Transaction Management  Security  Custom Aspects  Profiling  Caching  Rules  38
  • 39. Annotations • Added in Java SE 5.0 as Java Metadata facility (JSR 175). • Provide a way to add metadata to program elements. • Defined by nearly every recent JSR standard. • Also include a mechanism for adding custom annotations to the Java code*. 39
  • 40. Annotations For Domain Elements Layer Domain Element Annotation Domain Entity, @Entity (JPA), Value Object @Configurable Domain Repository @Repository Domain Service @Service Application Controller @Controller All All @Component 40
  • 41. Custom Annotations Use Cases • Caching • Validation 41
  • 42. Custom Annotations • Implementation Options • Reflection • Annotation Processing Tool (APT) • Byte-code Instrumentation (Javassist) • Aspects/AOP (AspectJ and Spring AOP) 42
  • 43. Agenda • Domain Driven Design & Development • Spring Portfolio • Dependency Injection / AOP / Annotations • Spring Security (Demo) • Architecture Enforcement (Demo) • Code Generation (Demo) • Conclusions 43
  • 44. Domain Aspects Data Access  Persistence  Transaction Management  Domain Security  Business Operation Retry  Caching  44
  • 45. Persistence & Txn Management JDBC  JPA w/ Hibernate, OpenJPA, EclipseLink  (TopLink) Spring JPA Utils & Data Source DI  Spring JTA Support  – Transactions are managed in Service classes using quot;@Transactionalquot; annotation 45
  • 46. Spring Security Declarative Application Security support  Fits in very well with Spring Framework  Authentication  Authorization  URL level  Domain Object  Service Method  46
  • 47. DEMO 47
  • 48. Agenda • Domain Driven Design & Development • Spring Portfolio • Dependency Injection / AOP / Annotations • Spring Security (Demo) • Architecture Enforcement (Demo) • Code Generation (Demo) • Conclusions 48
  • 49. Architecture Enforcement • Domain Driven Design Rules • Enforcement using Aspects and AOP 49
  • 50. Rules – Compile Time Service classes should not depend on  Application layer classes DAO classes should only be called from  Domain classes 50
  • 51. DEMO 51
  • 52. Rules – Run Time Business operation retry  Caching  System Settings (using AOP)  Application Variables/Business Data (using  Annotations) 52
  • 53. DEMO 53
  • 54. Agenda • Domain Driven Design & Development • Spring Portfolio • Dependency Injection / AOP / Annotations • Spring Security (Demo) • Architecture Enforcement (Demo) • Code Generation (Demo) • Conclusions 54
  • 55. Code Generation Write: XSD  Domain / Service  Code Generate: DAO interface and implementation  Facade (EJB's & WebServices)  DTO's  Unit Tests (including test data)  Spring configuration files  55
  • 56. Code Generation Tools openArchitectureWare (oAW)  AndroMDA  Aceleo Spring Module  Skyway Builder  56
  • 57. DEMO 57
  • 58. Tools Spring for:  Scheduling (Quartz)  Configuration Management (Commons  Configuration, JMX) Hibernate Tools (for DDL generation)  Dozer (DO/DTO Assembly)  58
  • 59. DDD Lifecycle Diagram Revisited 59
  • 60. Agenda • Domain Driven Design & Development • Spring Portfolio • Dependency Injection / AOP / Annotations • Spring Security (Demo) • Architecture Enforcement (Demo) • Code Generation (Demo) • Conclusions 60
  • 61. Conclusions • Domain First, Infrastructure Second • Layered Architecture & Separation of Concerns • Always keep the quot;contextquot; in mind • Balance between the quot;rightquot; vs. the quot;right nowquot; • Upcoming Java/JEE releases focus on development & deployment simplicity • Spring 3.0, Java EE 6, JPA 2.0, EJB 3.1 61
  • 62. References • Domain Driven Design and Development In Practice (http://www.infoq.com/articles/ddd-in-practice) • Domain-Driven Design Website (http://www.domaindrivendesign.org/) • Domain-Driven Design by Eric Evans • Applying Domain-Driven Design and Patterns, Jimmy Nilsson • Patterns of Enterprise Application Architecture, Martin Fowler • Can DDD be Adequately Implemented Without DI and AOP (http://www.infoq.com/news/2008/02/ddd-di-aop) 62
  • 63. Contact Information • Domain-Driven Design and Enterprise Architecture articles on InfoQ. • InfoQ website (http://www.infoq.com) • E-Mail: srinipenchikala@gmail.com • Blog: http://srinip2007.blogspot.com 63
  • 64. Q&A 64
  • 65. Thank You • Thank you for your attention • Feedback survey 65