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

The Shape of a Service Object

The Shape of a Service Object

Ivan Nemytchenko

September 11, 2024
Tweet

More Decks by Ivan Nemytchenko

Other Decks in Programming

Transcript

  1. Who am I and why am I here - Age:

    on Rails since 2006 - Current role: CTO at setyl.com - Passion: Complexity organization optimization - At my agency: RBBR Limited - Methodology: “Painless Rails“ - My twittter: x.com/inemation - My stuff: taplink.cc/inem
  2. Painless RAILS 1. Layered Architecture 2. Abstractions of a Single

    Level 3. Building blocks per type of work done by code
  3. Martin fowler Patterns of Enterprise Application Architecture Service layer: •

    separates domain logic from application logic • de fi nes application boundary
  4. Martin fowler Patterns of Enterprise Application Architecture Service layer: •

    separates domain logic from application logic • de fi nes application boundary • sets available operations
  5. Martin fowler Patterns of Enterprise Application Architecture Service layer: •

    separates domain logic from application logic • de fi nes application boundary • sets available operations • coordinates domain objects
  6. Martin fowler Patterns of Enterprise Application Architecture Service layer: •

    separates domain logic from application logic • de fi nes application boundary • sets available operations • coordinates domain objects • controls transactions
  7. Martin fowler Patterns of Enterprise Application Architecture Service layer: •

    separates domain logic from application logic • de fi nes application boundary • sets available operations • coordinates domain objects • controls transactions • encapsulates the app's business logic
  8. Martin fowler Patterns of Enterprise Application Architecture Service layer: •

    separates domain logic from application logic • de fi nes application boundary • sets available operations • coordinates domain objects • controls transactions • encapsulates the app's business logic • coordinates responses
  9. Martin fowler Patterns of Enterprise Application Architecture Service layer: •

    separates domain logic from application logic • de fi nes application boundary • sets available operations • coordinates domain objects • controls transactions • encapsulates the app's business logic • coordinates responses
  10. Martin fowler Patterns of Enterprise Application Architecture Service layer: •

    separates domain logic from application logic • de fi nes application boundary • sets available operations • coordinates domain objects • controls transactions • encapsulates the app's business logic • coordinates responses
  11. Eric Evans Domain-Driven Design Domain Services: • are stateless •

    named for an activity rather than an entity • represent signi fi cant business domain processes/operations
  12. Eric Evans Domain-Driven Design Domain Services: • are stateless •

    named for an activity rather than an entity • represent signi fi cant business domain processes/operations • are distinct from technical services
  13. Eric Evans Domain-Driven Design Domain Services: • are stateless •

    named for an activity rather than an entity • represent signi fi cant business domain processes/operations • are distinct from technical services
  14. Eric Evans Domain-Driven Design Domain Services: • are stateless •

    named for an activity rather than an entity • represent signi fi cant business domain processes/operations • are distinct from technical services • may have side effects
  15. The message being sent to us Domain Services: • are

    stateless • named for an activity rather than an entity • represent signi fi cant business domain processes/operations • are distinct from technical services • may have side effects Service layer: • separates domain logic from application logic • de fi nes application boundary • sets available operations • coordinates domain objects • controls transactions • encapsulates the app's business logic
  16. The message being sent to us Domain Services: • are

    stateless • named for an activity rather than an entity • represent signi fi cant business domain processes/operations • are distinct from technical services • may have side effects Service layer: • separates domain logic from application logic • de fi nes application boundary • sets available operations • coordinates domain objects • controls transactions • encapsulates the app's business logic 🤔
  17. Technical services == Application logic? Service Layer consists of Domain

    Services, which are: • are stateless • named for an activity rather than an entity • represent signi fi cant operations • coordinate domain objects & control transactions • may have side effects The message being sent to us 🤔
  18. The message being sent to us is stateless named for

    an activity, not entity represents business operations coordinates domain objects controls transactions should theoretically have side effects no application logic Domain Service:
  19. The message being sent to us Domain Service: is stateless

    named for an activity, not entity represents business operations coordinates domain objects controls transactions should theoretically have side effects no application logic
  20. Fowler-Evans Service Ruler!! Domain Service: is stateless named for an

    activity, not entity represents business operations coordinates domain objects controls transactions should theoretically have side effects no application logic
  21. Recommendations • Don’t use the term Service Object • Don’t

    use Service Objects • Split your code by the types of work done by it • Types of work → Types of building blocks • Measure your services with Fowler-Evans ruler!