Confused about implementing Single Responsibility Principle

Posted by HichemSeeSharp on Programmers See other posts from Programmers or by HichemSeeSharp
Published on 2014-05-30T14:56:16Z Indexed on 2014/05/30 15:58 UTC
Read the original article Hit count: 280

Please bear with me if the question looks not well structured.

To put you in the context of my issue:

I am building an application that invoices vehicles stay duration in a parking. In addition to the stay service there are some other services. Each service has its own calculation logic.

Here is an illustration (please correct me if the design is wrong):

public abstract class Service
{
   public int Id { get; set; }
   public bool IsActivated { get; set; }
   public string Name { get; set }
   public decimal Price { get; set; }
}

public class VehicleService : Service
{   
   //MTM : many to many
   public virtual ICollection<MTMVehicleService> Vehicles { get; set; }
}

public class StayService : VehicleService
{

}

public class Vehicle
{
   public int Id { get; set; }
   public string ChassisNumber { get; set; }
   public DateTime? EntryDate { get; set; }
   public DateTime? DeliveryDate { get; set; }
   //...
   public virtual ICollection<MTMVehicleService> Services{ get; set; }
}

Now, I am focusing on the stay service as an example:
I would like to know at invoicing time which class(es) would be responsible for generating the invoice item for the service and for each vehicle? This should calculate the duration cost knowing that the duration could be invoiced partially so the like is as follows: not yet invoiced stay days * stay price per day.

At this moment I have InvoiceItemsGenerator do everything but I am aware that there is a better design.

© Programmers or respective owner

Related posts about design-patterns

Related posts about object-oriented