Domain Logic Patterns

Goal: Business logic should usualy interact with database.

There are three main Domain Logic Patterns:

  1. Transaction Script: One class for one transaction type, that interacts with database
  2. Domain Model: Each object represens a database entry
  3. Table Module: One class handles business logic for a table

Transaction Script

Create new transaction class for each new business action.

Easy, but can get messy, does not scale.

Untitled

Domain Model

Best organization, but mapping can be complex.

Note: DatabaseAccess is a private field, that would be passed to constructor.

Note: Interaction with Account as with single object, that is already initialized and syncronized with database.

Untitled

Table Module

Easy mapping, but no object instances: can be bad for complex logic.

Note: DatabaseAccess is a private field, that would be passed to constructor.

Untitled