Create a gist now

Instantly share code, notes, and snippets.

@vkhorikov /1.cs
Last active Feb 15, 2018

Embed
What would you like to do?
Using Value Objects to represent technical concerns
public class Customer
{
public string Name { get; set; }
public string Email { get; set; }
}
Customer customer = GetCustomer();
customer.Name = customer.Email; // Compiles perfectly
public class Customer
{
public Optional70LimitedString Name { get; set; }
public Optional70LimitedString Email { get; set; }
}
Customer customer = GetCustomer();
customer.Name = customer.Email; // Compiles perfectly
public class Customer
{
public CustomerName Name { get; set; }
public Email Email { get; set; }
}
Customer customer = GetCustomer();
customer.Name = customer.Email; // Doesn't compile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment