Domain-Driven Design & REST

Domain-Driven Design & REST

Slides of the talk I gave at JAX 2016, Mayence.

@springcentral

977c74bb044a9d4fa90b305824eda390?s=128

Oliver Drotbohm

April 19, 2016
Tweet

Transcript

  1. 2.

    2

  2. 7.
  3. 8.

    8

  4. 9.

    8

  5. 11.

    Stringly typed code 10 public class Customer { private Long

    id; private String firstname, lastname, email; … }
  6. 12.

    Stringly typed code 11 public class SomeService { public void

    createUser(String firstname,
 String lastname, String email) { … } }
  7. 13.

    12 public class Customer { private Long id; private Firstname

    firstname; private Lastname lastname; private EmailAddress emailAddress; … }
  8. 15.

    Still, they’re worth it. 14 See „Power Use of Value

    Objects in DDD“ by Dan Bergh Johnsson.
  9. 17.

    16 @Value public class Customer { UUID id = UUID.randomUUID();

    Firstname firstname; Lastname lastname; EmailAddress email; @Value static class EmailAddress { String value; } }
  10. 33.

    29 Level 0: No events at all Level 1: Explicit

    operations Level 2: Some operations as events
  11. 36.

    32 Level 0: No events at all Level 1: Explicit

    operations Level 2: Some operations as events
  12. 37.

    32 Level 0: No events at all Level 1: Explicit

    operations Level 2: Some operations as events Level 3: Event Sourcing
  13. 38.
  14. 48.

    43 Aggregate Root / Repository Collection / Item Resources IDs

    URIs @Version ETags Last Modified Property Last Modified Header Relations Links
  15. 50.

    Method URI Action Step POST /orders Create new order 1

    POST/PATCH /orders/{id} Update the order (only if "payment expected") 2 DELETE /orders/{id} Cancel order (only if "payment expected") 3 PUT /orders/{id}/payment Pay order (only if "payment expected") 4 Barista preparing the order GET /orders/{id} Poll order state 5 GET /orders/{id}/receipt Access receipt DELETE /orders/{id}/receipt Conclude the order process 6
  16. 51.

    Method Resource type Action Step POST orders Create new order

    1 POST/PATCH update Update the order 2 DELETE cancel Cancel order 3 PUT payment Pay order 4 Barista preparing the order GET order Poll order state 5 GET receipt Access receipt DELETE receipt Conclude the order process 6
  17. 53.

    Web Service Repository - Orders Spring Data Spring Data
 REST

    Payment Spring Data Manual
 implementation Manual
 implementation