ArchDeck · 115 cards

← All families
Open full library ↗
← Back to family

G3 · Architecture Generations

Services

Encapsulating Business Capabilities

Overview

Business logic deserves its own layer. Services encapsulate domain rules, enable reuse across controllers, and make complex logic testable in isolation. The workhorse of enterprise applications.

When to use

  • Complex business rules
  • Logic reused across multiple entry points
  • Testing business rules in isolation
  • Clear domain boundaries emerging

Quick assessment

  • Is business logic duplicated across controllers?
  • Do domain rules warrant dedicated attention?
  • Would isolated testing of business logic be valuable?
  • Are you building for long-term maintainability?

In practice

How it works

The service coordinates; domain objects enforce invariants.

Make it work

Define one capability and a small interface. Use domain objects for business decisions and repository interfaces for stored state.

The trade-off

Pass-through services add little value. Huge services and circular dependencies obscure ownership.

What single capability does this service own?

Key patterns

  • Services per business capability
  • Controllers as thin routing layer
  • Repository pattern for data access
  • Dependency injection for flexibility

Counter-patterns

  • Anemic services (just pass-through)
  • Services that know about HTTP
  • Circular dependencies between services
  • One god service for everything

Reality check

Services bring testability and organization. But as domains get richer, you may find reads and writes have fundamentally different needs. That tension leads to CQRS.

NFR profile

security
3/5
usability
3/5
performance
3/5
reliability
4/5
scalability
3/5
testability
4/5
availability
3/5
extensibility
4/5
maintainability
4/5
Explore the full library and printable cards