Skip to content

Review domain is refactored #123

@kubazuch

Description

@kubazuch

DDD plan

  • code is separated into layers: API (controller), domain (model + service), infra (repository)
  • layers communicate like: Controller -> Service -> Repository and ONLY like that.
  • Service can use other Services, Repository can use other Repositories, Service can use only one Repository!
  • If endpoint has a PUT edit endpoint, it should ideally also have a PATCH edit endpoint, where PUT takes whole object, and PATCH just some of the object fields.

API layer

  • input data validation, conversion, etc. should be handled in Controller
  • Controller can call Service, controller also uses Dtos and Mappers
  • Controller is the only place in the app that knows about users as in their credentials and authorities
  • Use Authentication authentication as parameter and authentication.getPrincipal() to get logged in User
  • Use @...Mapping(params = ...) to separate logic depending on parameter

Domain layer

  • Services return Model objects, there are no Dtos in any Service
  • Exceptions are thrown in Services
  • Thrown exceptions are semantic!

Infrastructure layer

  • All SQL calls are prepared to do things in the DBMS
  • No tolerance for situations such as getting huge amounts of data from database just to filter it in backend

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions