Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Applied DDD in a Java EE 7 and Open Source World

Applied DDD in a Java EE 7 and Open Source World

We’ve observed the 10th anniversary of “domain-driven design,” but 10 years later, how are we applying these concepts in the Java world? Java EE 7 leveraged the Java platform to an outstanding level, enabling our code to be clean, efficient, and testable—yet most Java EE applications out there are still structured in a procedural way. This session takes a deep look at how Java EE 7 specs such as JPA, JSF, EJB, and CDI can work together with open source libraries such as Guava, Spring Data, and Query DSL to provide a rich domain model definition. The presentation revisits how to apply DDD concepts with type safety, immutability, and proper encapsulation and do some live coding showing how these can be implemented step-by-step with common design patterns and Java 8.

Edson Yanaga

October 02, 2014
Tweet

More Decks by Edson Yanaga

Other Decks in Technology

Transcript

  1. A P P L I E D D D D

    I N A J AVA E E 7 A N D O P E N S O U R C E W O R L D E d s o n Ya n a g a @ y a n a g a # J AVA O N E
  2. E D S O N YA N A G A

    • Computer Science Bachelor’s Degree • Electrical Engineer Master’s Degree • Java Developers since 1997 • Unix Systems Administrator since 1999 • Professor of graduate and undergraduate courses since 2000
  3. C E R T I F I C AT I

    O N S • Oracle Certified Professional, Java Platform, Enterprise Edition 6 Enterprise JavaBeans Developer • Sun Certified Enterprise Architect for the Java Platform,Enterprise Edition 5 (i) • Certified ScrumMaster • Sun Certified Developer for Java Web Services 5 • Sun Certified Specialist for NetBeans IDE • Sun Certified Web Component Developer for J2EE 1.4 • Sun Certified Programmer for Java 2 Platform 1.4
  4. W H AT H AV E Y O U L

    E A R N E D A B O U T O B J E C T O R I E N T E D A N A LY S I S & D E S I G N ?
  5. public class Person { ! private String name; private String

    ssn; private String telephone; private Date birth; ! }
  6. P R I M I T I V E O

    B S E S S I O N
  7. public class Person { ! private Name name; private Ssn

    ssn; private Telephone telephone; private Birth birth; ! }
  8. – D E M E T E R L A

    W “Don’t talk to strangers”
  9. CriteriaQuery query = builder.createQuery();! Root<Person> men = query.from( Person.class );!

    Root<Person> women = query.from( Person.class );! Predicate menRestriction = builder.and(! ! builder.equal( men.get( Person_.gender ), Gender.MALE ),! ! builder.equal( men.get( Person_.relationshipStatus ),! RelationshipStatus.SINGLE ));! Predicate womenRestriction = builder.and(! ! builder.equal( women.get( Person_.gender ), Gender.FEMALE ),! ! builder.equal( women.get( Person_.relationshipStatus ),! RelationshipStatus.SINGLE ));! query.where( builder.and( menRestriction, womenRestriction ) );!
  10. JPAQuery query = new JPAQuery(em);! QPerson men = new QPerson("men");!

    QPerson women = new QPerson("women");! query.from(men, women).where(! ! men.gender.eq(Gender.MALE),! ! men.relationshipStatus.eq(RelationshipStatus.SINGLE),! ! women.gender.eq(Gender.FEMALE),! ! women.relationshipStatus.eq(RelationshipStatus.SINGLE));!
  11. T H E N D O I T F O

    R Y O U ! D O N ’ T C A R E ?
  12. – H E N RY F O R D If

    you think you can do a thing or think you can't do a thing, you're right.
  13. B E T T E R S O F T

    WA R E , B E T T E R W O R L D
  14. S O U R C E C O D E

    AVA I L A B L E O N : h t t p s : / / g i t h u b . c o m / y a n a g a / d d d - j a v a e e 7
  15. E D S O N YA N A G A

     ! e d s o n @ y a n a g a . c o m . b r  @ y a n a g a  w w w. y a n a g a . c o m . b r