All Projects → rafaelfgx → DDD

rafaelfgx / DDD

Licence: MIT license
Domain-Driven Design is a software development approach in which it utilizes concepts and good practices related to object-oriented programming.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to DDD

eventuous
Minimalistic Event Sourcing library for .NET
Stars: ✭ 236 (+362.75%)
Mutual labels:  ddd, domain-driven-design
Clean-Architecture-Template
Configurable Clean Architecture template containing the DDD + CQRS approach for .NET Core applications.
Stars: ✭ 14 (-72.55%)
Mutual labels:  ddd, domain-driven-design
business
Based on the Domain-Driven-Design approach, the business framework will help you structure and implement your business code cleanly and efficiently.
Stars: ✭ 23 (-54.9%)
Mutual labels:  ddd, domain-driven-design
tactical-ddd
lightweight helpers that I find myself implementing over and over again related to DDD/Event Sourcing tactical patterns, such as Value Objects, Entities, AggregateRoots, EntityIds etc...
Stars: ✭ 33 (-35.29%)
Mutual labels:  ddd, domain-driven-design
e-shop
Sample Spring Cloud microservices e-shop.
Stars: ✭ 48 (-5.88%)
Mutual labels:  ddd, domain-driven-design
clean-architecture
Package for isolate your domain code from framework dependency using DDD concepts.
Stars: ✭ 93 (+82.35%)
Mutual labels:  ddd, domain-driven-design
ddderr
👺 Reflection-free Domain-Driven errors for Go.
Stars: ✭ 29 (-43.14%)
Mutual labels:  ddd, domain-driven-design
Messagebus
A MessageBus (CommandBus, EventBus and QueryBus) implementation in PHP7
Stars: ✭ 178 (+249.02%)
Mutual labels:  ddd, domain-driven-design
ddd-referenz
Deutsche Übersetzung der DDD Referenz von Eric Evans
Stars: ✭ 58 (+13.73%)
Mutual labels:  ddd, domain-driven-design
ddd-house
🏠 Building a house with DDD
Stars: ✭ 38 (-25.49%)
Mutual labels:  ddd, domain-driven-design
Dotnet New Caju
Learn Clean Architecture with .NET Core 3.0 🔥
Stars: ✭ 228 (+347.06%)
Mutual labels:  ddd, domain-driven-design
typescript-ddd-example
🔷🎯 TypeScript DDD Example: Complete project applying Hexagonal Architecture and Domain-Driven Design patterns
Stars: ✭ 607 (+1090.2%)
Mutual labels:  ddd, domain-driven-design
Run Aspnetcore
A starter kit for your next ASP.NET Core web application. Boilerplate for ASP.NET Core reference application, demonstrating a layered application architecture with applying Clean Architecture and DDD best practices. Download 100+ page eBook PDF from here ->
Stars: ✭ 227 (+345.1%)
Mutual labels:  ddd, domain-driven-design
repository
[PHP 7] Implementation and definition of a base Repository in Domain land.
Stars: ✭ 26 (-49.02%)
Mutual labels:  ddd, domain-driven-design
Library
This is a project of a library, driven by real business requirements. We use techniques strongly connected with Domain Driven Design, Behavior-Driven Development, Event Storming, User Story Mapping.
Stars: ✭ 2,685 (+5164.71%)
Mutual labels:  ddd, domain-driven-design
finance-project-ddd
Projeto financeiro usando domain driven design, tdd, arquitetura hexagonal e solid
Stars: ✭ 67 (+31.37%)
Mutual labels:  domain-driven-design, domain
Architecture
.NET 6, ASP.NET Core 6, Entity Framework Core 6, C# 10, Angular 13, Clean Code, SOLID, DDD.
Stars: ✭ 2,285 (+4380.39%)
Mutual labels:  ddd, domain-driven-design
Kreta
Modern project management solution
Stars: ✭ 177 (+247.06%)
Mutual labels:  ddd, domain-driven-design
EcommerceDDD
Experimental full-stack application using Domain-Driven Design, CQRS, and Event Sourcing.
Stars: ✭ 178 (+249.02%)
Mutual labels:  ddd, domain-driven-design
educational-platform
Modular Monolith Java application with DDD
Stars: ✭ 124 (+143.14%)
Mutual labels:  ddd, domain-driven-design

Domain-Driven Design

Domain-Driven Design is a software development approach in which it utilizes concepts and good practices related to object-oriented programming.

Books

Domain-Driven Design: Tackling Complexity in the Heart of Software - Eric Evans Implementing Domain-Driven Design - Vaughn Vernon

Tests

[TestClass]
public class Tests
{
    [TestMethod]
    public void Email()
    {
        Assert.IsTrue(new Email("domain.com").Invalid);
        Assert.IsTrue(new Email(string.Empty).Invalid);
        Assert.IsTrue(new Email("[email protected]").Valid);
    }

    [TestMethod]
    public void Order()
    {
        var customer = CustomerFactory.Create("Luke", "Skywalker", "[email protected]");

        var product = ProductFactory.Create("Millennium Falcon", 500_000_000);

        var item = OrderItemFactory.Create(product, 1);

        var order = OrderFactory.Create(customer);

        order.AddItem(item);

        var discount = new DiscountService().Calculate(order.Total, DiscountType.Large);

        order.ApplyDiscount(discount);

        Assert.AreEqual(250_000_000, order.Total.Value);
    }
}

Customer

public sealed class Customer : Entity
{
    public Customer(FullName fullName, Email email)
    {
        FullName = fullName;
        Email = email;
    }

    public Email Email { get; private set; }

    public FullName FullName { get; private set; }

    public void ChangeEmail(Email email)
    {
        Email = email;
    }

    public void ChangeFullName(FullName fullName)
    {
        FullName = fullName;
    }
}
public static class CustomerFactory
{
    public static Customer Create(string firstName, string lastName, string email)
    {
        return new Customer(new FullName(firstName, lastName), new Email(email));
    }
}

Product

public sealed class Product : Entity
{
    public Product(string description, Amount price)
    {
        Description = description;
        Price = price;
    }

    public string Description { get; private set; }

    public Amount Price { get; private set; }

    public void ChangeDescription(string description)
    {
        Description = description;
    }

    public void ChangePrice(Amount price)
    {
        Price = price;
    }
}
public static class ProductFactory
{
    public static Product Create(string description, decimal price)
    {
        return new Product(description, new Amount(price));
    }
}

Order

public sealed class Order : Entity
{
    public Order(Customer customer)
    {
        Customer = customer;
        Discount = new Amount(0);
        Items = new List<OrderItem>();
    }

    public Customer Customer { get; private set; }

    public Amount Discount { get; private set; }

    public IReadOnlyList<OrderItem> Items { get; private set; }

    public Amount Total => new Amount(Items.Sum(item => item.SubTotal.Value) - Discount.Value);

    public void AddItem(OrderItem item)
    {
        Items = new List<OrderItem>(Items) { item };
    }

    public void ApplyDiscount(Amount discount)
    {
        Discount = discount;
    }
}
public static class OrderFactory
{
    public static Order Create(Customer customer)
    {
        return new Order(customer);
    }
}

Order Item

public sealed class OrderItem : Entity
{
    public OrderItem(Product product, Quantity quantity)
    {
        Product = product;
        Quantity = quantity;
    }

    public Product Product { get; private set; }

    public Quantity Quantity { get; private set; }

    public Amount SubTotal => new Amount(Product.Price.Value * Quantity.Value);
}
public static class OrderItemFactory
{
    public static OrderItem Create(Product product, decimal quantity)
    {
        return new OrderItem(product, new Quantity(quantity));
    }
}

Discount

public enum DiscountType
{
    Small = 1,
    Medium = 2,
    Large = 3
}
public sealed class DiscountService
{
    public Amount Calculate(Amount amount, DiscountType type)
    {
        var discount = Factory.Get<IDiscount>(x => x.IsApplicable(type));

        if (discount == null) { return amount; }

        return discount.Calculate(amount);
    }
}
public interface IDiscount
{
    Amount Calculate(Amount amount);

    bool IsApplicable(DiscountType type);
}
public sealed class SmallDiscount : IDiscount
{
    public Amount Calculate(Amount amount)
    {
        return new Amount(amount.Value * 0.1M);
    }

    public bool IsApplicable(DiscountType type) => type == DiscountType.Small;
}
public sealed class MediumDiscount : IDiscount
{
    public Amount Calculate(Amount amount)
    {
        return new Amount(amount.Value * 0.25M);
    }

    public bool IsApplicable(DiscountType type) => type == DiscountType.Medium;
}
public sealed class LargeDiscount : IDiscount
{
    public Amount Calculate(Amount amount)
    {
        return new Amount(amount.Value * 0.5M);
    }

    public bool IsApplicable(DiscountType type) => type == DiscountType.Large;
}

Value Objects

public sealed record Amount(decimal Value)
{
    public override string ToString() => Value.ToString();
}
public sealed record Email(string Value)
{
    public bool Invalid => !Valid;

    public bool Valid
    {
        get
        {
            if (string.IsNullOrWhiteSpace(Value)) { return false; }

            const string regex = @"^([a-z0-9_\.\-]{3,})@([\da-z\.\-]{3,})\.([a-z\.]{2,6})$";

            return new Regex(regex).IsMatch(Value);
        }
    }

    public override string ToString() => Value.ToString();
}
public sealed record FullName(string FirstName, string LastName)
{
    public override string ToString() => $"{ FirstName } { LastName }";
}
public sealed record Quantity(decimal Value)
{
    public override string ToString() => Value.ToString();
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].