PEAA.2 – Organizing Domain Logic

Properly organizing the code and specially the domain logic is crucial for the maintainability of a project.

Personally, it reminds me of a book store or library: If we put a book in the wrong shelve, the people looking for the book will not find it, it will be lost, another copy of the book will be ordered, catalogued and stored in some other place, hopefully in the correct place where people will find it and therefore use it.

It happens the same with our code, if we don’t have a clear place to put a specific code unit, the developers (our colleagues or even one self) will not know of its existence, they will think it does not exist, they will create it again (wasting time, wasting resources, duplicating code, …), they will create it slightly differently, introducing inconsistency throughout the code base.

The folders we use in the project structure should correspond to bounded contexts, which correspond to business concepts, and in them there should be a clear functional separation, a separation per code unit role. Continue reading “PEAA.2 – Organizing Domain Logic”

Advertisements

PEAA.1 – Layering

Layering is a common practice to separate and organise code units by their role/responsibilities in the system.

In a layered system, each layer:

  • Depends on the layers beneath it;
  • Is independent of the layers on top of it, having no knowledge of the layers using it.

Continue reading “PEAA.1 – Layering”