liveBook · Manning

Domain model

As explained in AI-Powered Developer: Build software with ChatGPT and Copilot

A domain model is the representation of an application’s core business logic, including domain entities, value objects, and domain services.

A domain model holds an application’s core business logic: its entities, value objects, domain services, rules, responsibilities, and workflows. It stays independent of external systems and implementation details such as databases and APIs. In hexagonal architecture, it sits at the center, while ports and adapters connect it to the outside world. section 3.3 section 4.1

Treat the model as the place where business rules are applied and enforced. Build it before wiring infrastructure, then use generated code as a starting point: compare variations, understand why they differ, and refine the design rather than accepting an output unchanged. section 4.0

IT asset management model

An IT asset management model can begin with Hardware inheriting from Asset. Asset contains FundingDetails, and a DepreciationStrategy interface allows different depreciation calculations—straight-line, declining-balance, double-declining, or none—to be substituted without changing the asset’s role. section 3.3

Evolve a domain model by making business relationships explicit:

  • Add an Asset parent when Hardware needs shared identity, status, category, and funding details. section 3.3
  • Replace a simple funding-details field with FundingDetails when that information gains its own responsibilities. section 3.3
  • Model alternative depreciation rules behind DepreciationStrategy when calculation behavior must be swappable. section 3.3
Figure 3.5 We have added a depreciation strategy to our object model. This introduction allows us to swap out the method by which we can calculate the depreciation of an asset.

Inspect the strategy-based design to see how a domain model separates an asset’s business data from interchangeable depreciation behavior. section 3.3

How AI-Powered Developer: Build software with ChatGPT and Copilot covers it

How deep it goes
Defines the model’s isolation and responsibilities, then develops an ITAM class design through successive refinements.
Examples
Uses an IT asset management design with Hardware, Asset, FundingDetails, and alternative depreciation strategies.
What you can do after
Apply it via GitHub Copilot to build classes that apply and enforce business rules.
How it connects
Connects hexagonal architecture with ports, adapters, entities, value objects, domain services, and the Strategy pattern.

Also explained in

Compare how 8 books explain domain model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI-Powered Developer: Build software with ChatGPT and Copilot. The section links point to the parts of the book it draws on.