Requirement:
If the bookshop manager field changes from A to B, I need to email the person B saying that the new Bookshop has been allotted to him and he has to do certain activities.
Here is my method
private void SendEmailToAllottedManager()
{
EmailExpress mEmailExpress = new EmailExpress();
mEmailExpress.SendEmail(Shop.Bookstore.BookstoreName, Subject);
}
In the method where I am calling SendEmailToAllottedManager, I am checking if the Manager has indeed changed or not as below -
if (OriginalManager != CurrentManager)
{
SendEmailToAllottedManager();
}
During code review, a colleague suggested that I move the check from outside the function SendEmailToAllottedManager() to inside it.
Proposed Code
private void SendEmailToAllottedManager()
{
if (OriginalManager != CurrentManager)
{
EmailExpress mEmailExpress = new EmailExpress();
mEmailExpress.SendEmail(Shop.Bookstore.BookstoreName, Subject);
}
}
I maintain my stand that the function SendEmailToAllottedManager is only about emailing and not about performing the checks etc.,
What do you think?
SendEmailToManagerIfRequired
– Grant Thomas Jul 15 '11 at 12:28