I have a requirement where system sends email. Currently the system sends user's first name in email and it's in production and working fine.
Now my client asked to add last name as well in email, so I extended the send(User userinfo) method and this is also working fine.
Now client again asked to add email in email, later on again client asked to add mobile and so on more user's information in email.
How to manage this with open-closed principle of solid principle while client is frequently asking for changes in the same feature? Code
` class User
{
public int userId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Mobile { get; set; }
}
interface Email
{
void send(User userInfo);
}
class UserEmail : Email
{
public void send(User userInfo)
{
// Sends users firstname
//Email Send code
}
}
class NewUserEmail : Email
{
public void send(User userInfo)
{
// Sends users Lirstname + Lastname
//Email Send code
}
}
`