Domain

The business rules on the Devprime platform are isolated in a project called “Domain”, following the principles of Domain-Driven Design (DDD). This results in simplified maintenance, decoupling, reuse, and testability, as well as providing predictability across all projects.

The Domain is the place where the business features of the application are defined and implemented, ensuring a clear organization and a solid foundation for development.

These business rules are developed by the software developer using C#/Csharp and follow the standardized practices of Domain Driven Design (DDD).

Devprime domain

Standardization of business rules

The technology of the Devprime platform standardizes the business rules following the main concepts of Domain Driven Design (DDD) such as Bounded context, Aggregate roots, Value Objects, Entity, Domain Events, Domain services, Application services, Handler based on Devprime Foundation.

Devprime domain

Strategy based on Domain Driven Design (DDD)

Devprime Domain’s strategy, in addition to standardizing development, simplifies the entry of new developers into the project and the switching to other projects, enabling predictability in software development.

Domain
Context map A map representing the interaction between business contexts
Bounded context Grouping business rules with common responsibility in one context.
Aggregate roots A main context grouping a set of business rules with all the implementations self-contained within it
Value Objects Immutable business object and does not have an identifier
Entity Business object with an identifier and the ability to be modified.
Domain Events Strategy for Communicating Business Facts
Core
Domain services Implementation of business rules between various aggregates
Application services The first level of contact with business objectives (Aggregate or Domain services).
Handler It plays the role of a communication bridge, reacting to domain events and interacting with technological interfaces

Defining Devprime Foundation-based types

The source code of business rules based on the Devprime platform is natively typed in Domain-Driven Design (DDD), through the Devprime Foundation classes. This enables validations through the Devprime CLI and the execution of Devprime platform accelerators, which implement standard behaviors such as exposing APIs, tests, repositories, and other implementations.

**Viewing an “Aggregate root” class

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
namespace Domain.Aggregates.Order;
public class Order : AggRoot
{
    public string CustomerName { get; private set; }
    public string CustomerTaxID { get; private set; }
    public IList<Item> Items { get; private set; }
    public double Total { get; private set; }
    public void AddItem(Item item)
    {
        if (item != null && Items != null)
        {
            var myItems = Items.Where(p => p.SKU == item.SKU).FirstOrDefault();
            if (myItems != null)
                myItems.Sum(item.Amount);
            else
                Items.Add(item);
        }
    }
}

Viewing an Aggregate Entity Class

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
namespace Domain.Aggregates.Order;
public class Item : Entity
{
    public string Description { get; private set; }
    public int Amount { get; private set; }
    public string SKU { get; private set; }
    public double Price { get; private set; }
    public double GetSubTotal()
    {
        return Amount * Price;
    }
    public void Sum(int amount)
    {
        Amount += amount;
    }
}

Last modified January 10, 2024 (967dcac3)