Skip to content

Instantly share code, notes, and snippets.

View maiconheck's full-sized avatar

Maicon Heck maiconheck

View GitHub Profile
public class PhoneNumber
{
public PhoneNumber(string ddd, string number)
{
Guard.Against
.NotMatch(ddd, @"^\d{2}$", nameof(ddd))
.NotMatch(number, @"^\d{8}$|^\d{9}$", nameof(number));
Ddd = ddd;
Number = number;
public class Email
{
public Email(string emailAddress)
{
Guard.Against.InvalidEmail(emailAddress);
EmailAddress = emailAddress;
}
public string EmailAddress { get; }
public class Name
{
public Name(string firstName, string lastName = "")
{
Guard.Against.NullOrWhiteSpace(firstName, nameof(firstName));
FirstName = firstName;
LastName = lastName;
}
@maiconheck
maiconheck / Lead.cs
Last active June 20, 2023 13:45
[3º Improvement]
public class Lead
{
public Lead(string name, string email)
{
Name = name;
Email = email;
_segments = new List<Segment>();
}
public string Name { get; }
@maiconheck
maiconheck / Lead.cs
Last active June 20, 2023 12:34
[2º improvement] An anemic entity sample for blog posting.
public class Lead
{
// Initializing Segments to avoid an exception.
public Lead(string name, string email)
{
Name = name;
Email = email;
_segments = new List<Segment>();
}
@maiconheck
maiconheck / Lead.cs
Last active June 20, 2023 12:24
[1º improvement] An anemic entity sample for blog posting.
public class Lead
{
// The minimum data needed to create a Lead instance.
// The name and e-mail are the minimum necessary for a Lead to exist. Remember?
public Lead(string name, string email)
{
Name = name;
Email = email;
}
@maiconheck
maiconheck / Lead.cs
Last active February 3, 2021 11:47
An anemic entity sample for blog posting.
public class Lead
{
public string Name { get; set; }
public string Email { get; set; }
public IList<Segment> Segments { get; set; }
public string Company { get; set; }