Skip to content

Instantly share code, notes, and snippets.

@vkhorikov
Last active February 15, 2018 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vkhorikov/dcbf961842d72bc0d3db60abb5f0a901 to your computer and use it in GitHub Desktop.
Save vkhorikov/dcbf961842d72bc0d3db60abb5f0a901 to your computer and use it in GitHub Desktop.
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