All Projects → mcintyre321 → Valueof

mcintyre321 / Valueof

Licence: mit
Deal with Primitive Obsession - define ValueObjects in a single line (of C#).

Labels

Projects that are alternatives of or similar to Valueof

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 (+991.46%)
Mutual labels:  ddd
Node Api Boilerplate
DDD/Clean Architecture inspired boilerplate for Node web APIs
Stars: ✭ 2,797 (+1036.99%)
Mutual labels:  ddd
Adnc
微服务框架,同时也适用于单体架构系统的开发。支持经典三层与DDD架构开发模式、集成了一系列主流稳定的微服务配套技术栈。一个前后端分离的框架,前端基于Vue、后端基于.Net Core 3.1构建。
Stars: ✭ 223 (-9.35%)
Mutual labels:  ddd
Sculptor
Sculptor is a code generator that applies the concepts from Domain-Driven Design and Domain Specific Languages.
Stars: ✭ 220 (-10.57%)
Mutual labels:  ddd
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 (-7.72%)
Mutual labels:  ddd
Mediator.net
A simple mediator for .Net for sending command, publishing event and request response with pipelines supported
Stars: ✭ 237 (-3.66%)
Mutual labels:  ddd
Ddd Java
Spring Boot + Java [ DDD Sample ]
Stars: ✭ 191 (-22.36%)
Mutual labels:  ddd
Netcorekit
💗 A crafted toolkit for building cloud-native apps on the .NET platform
Stars: ✭ 248 (+0.81%)
Mutual labels:  ddd
Dotnet New Caju
Learn Clean Architecture with .NET Core 3.0 🔥
Stars: ✭ 228 (-7.32%)
Mutual labels:  ddd
Typescript Ddd Skeleton
🟨 TypeScript DDD Skeleton: Bootstrap your new projects or be inspired by this example project
Stars: ✭ 240 (-2.44%)
Mutual labels:  ddd
Netdevpack
A smart set of common classes and implementations to improve your development productivity.
Stars: ✭ 220 (-10.57%)
Mutual labels:  ddd
Typescript Clean Architecture
It is my attempt to create Clean Architecture based application in Typescript
Stars: ✭ 225 (-8.54%)
Mutual labels:  ddd
Event Sourcing
Provides basic functionality for event sourced aggregates.
Stars: ✭ 242 (-1.63%)
Mutual labels:  ddd
Ddd Base
DDD(Domain Driven Design) base package for java
Stars: ✭ 208 (-15.45%)
Mutual labels:  ddd
Ddd
A Domain Driven Design framework for software simplicity in node
Stars: ✭ 244 (-0.81%)
Mutual labels:  ddd
Migration
《系统重构与迁移指南》手把手教你分析、评估现有系统、制定重构策略、探索可行重构方案、搭建测试防护网、进行系统架构重构、服务架构重构、模块重构、代码重构、数据库重构、重构后的架构守护
Stars: ✭ 2,753 (+1019.11%)
Mutual labels:  ddd
Wolkenkit Boards
wolkenkit-boards is a team collaboration application.
Stars: ✭ 236 (-4.07%)
Mutual labels:  ddd
Proophessor Do
prooph components in action
Stars: ✭ 247 (+0.41%)
Mutual labels:  ddd
Cqrs Clean Eventual Consistency
CQRS, using Clean Architecture, multiple databases and Eventual Consistency
Stars: ✭ 247 (+0.41%)
Mutual labels:  ddd
Restairline
DDD+CQRS+EventSourcing+Hypermedia API+ASP.NET Core 3.1+Masstransit+terraform+docker+k8s
Stars: ✭ 243 (-1.22%)
Mutual labels:  ddd

ValueOf

install-package ValueOf

What is this library

The Smell: Primitive Obsession is using primitive data types to represent domain ideas. For example, we use a String to represent a message, an Integer to represent an amount of money, or a Struct/Dictionary/Hash to represent a specific object. The Fix: Typically, we introduce a ValueObject in place of the primitive data, then watch like magic as code from all over the system shows FeatureEnvySmell and wants to be on the new ValueObject. We move those methods, and everything becomes right with the world.

ValueOf lets you define ValueObject Types in a single line of code. Use them everywhere to strengthen your codebase.

public class EmailAddress : ValueOf<string, EmailAddress> { }

...

EmailAddress emailAddress = EmailAddress.From("[email protected]");

The ValueOf class implements .Equals and .GetHashCode() for you.

You can use C# 7 Tuples for more complex Types with multiple values:

    public class Address : ValueOf<(string firstLine, string secondLine, Postcode postcode), Address> { }

Validation

You can add validation to your Types by overriding the protected void Validate() { } method:

public class ValidatedClientRef : ValueOf<string, ValidatedClientRef>
{
    protected override void Validate()
    {
        if (string.IsNullOrWhiteSpace(Value))
            throw new ArgumentException("Value cannot be null or empty");
    }
}	

See Also

If you liked this, you'll probably like another project of mine OneOf which provides Discriminated Unions for C#, allowing stronger compile time guarantees when writing branching logic.

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].