We have recently started using c# and are currently having an internal debate on how our business logic classes should be structured. At the moment we structure our business classes like this:
public class OrderBL
{
public void CreateOrder(OrderDTO order)
{
//save order
//send email
}
public void CancelOrder(OrderDTO order)
{
//save order
//send email
}
public void MarkOrderAsDispatched(OrderDTO order)
{
//save order
//send email
}
//other private methods too
}
Using our current method above we find classes grow very quickly and can become confusing on big projects.
There is some debate as to whether we should change our business classes to look like the below (1 class for each operation, CreateOrder, CancelOrder etc):
public class CreateOrderBL
{
public void RunLogic(OrderDTO order)
{
CreateOrder();
SendEmail();
}
private voide CreateOrder()
{
}
private void SendEmail()
{
}
}
The benefit to having this is that classes are easier to understand and are small, however the downside is that the number of classes increase.
What is the correcty way to approach this?
Aucun commentaire:
Enregistrer un commentaire