Architecture Patterns

Table Module

A Table Module organizes domain logic with one class per table in the data-base, and a single instance of a class contains the various procedures that will act on the data. The primary distinction with Domain Model (116) is that, if you have many orders, a Domain Model (116) will have one order object per order while a Table Module will have one object to handle all orders.

When to use it? When the domain logic is very simple and you need to work with tabular data it could be a good option.


Active Record

A database table or view is wrapped into a class. Thus, an object instance is tied to a single row in the table. https://en.wikipedia.org/wiki/Active_record_pattern


Transaction script

Organizes business logic by procedures where each procedure handles a single request from the presentation.

  • Each business transaction corresponds to one transaction script. i.e:
    • Business transaction: Book a hotel room
    • Tasks: check room availabilty, calculate rates, update the database - all handled in one BookArommscript
  • Access the database directly
  • Don't call any logic in the presentation layer
  • Each script is in one class

When to use it? When the domain logic is very simple and transactions don't have a lot of overlap functionality.


Domain Model

An object model of the doman that incorporates both behavior and data. A Domain Model creates an application of interconnected objects, where each object represents some meaningful individual, whether as large as a corporation or as small as a single line on an order form.


Service Layer

Defines an application's boundary with a layer of services that establishes a set of available operations and coordinates the application's response in each operation.

https://martinfowler.com/eaaCatalog/


DDD

It's not an architecture pattern, it's more an artifact to build projects with a a lot of business functionallity. The Core layer will have the following sections:

Entites: An entity has to have an identification
Value Objects:Same than entity, but without Id, i.e: class Money with attributes Currency and Amount
Events: Definition of the Events if you are going to use Event Driven
Handlers: Handlers for the Events if you are going to use Event Driven
Interfaces
Services: If there is logic which involves different entities or aggregates you will need to create a Domain Service with this logic to avoid duplicate code.
Specificationshttps://fabiomarreco.github.io/blog/2017/a-generic-specification-pattern-in-c/


Comentarios