When developing interfaces, should they be kept as generic as possible or should you try to put as many methods, properties in an interface to keep the number of interfaces low: As an example, which is better 1 or 2:
1) Customer and Rental split into 2 interfaces (Data only relevant to a rental is in Rental interface and data only relevant to a customer is in the Customer interface)
interface ICustomer { public string Name { get; set; } public string Address { get; set; } public string Phone { get; set; } public string Email { get; set; } } interface IRental: ICustomer { string Title { get; set; } decimal Cost{ get; set; } void Rent(); } 2) Put all data into one interface.
interface IRental { string Title { get; set; } decimal Cost{ get; set; } void Rent(); public string Name { get; set; } public string Address { get; set; } public string Phone { get; set; } public string Email { get; set; } } Also regarding the first approach, is there a benefit to extending the ICustomer interface or should there just be an ICustomer property in IRental like the following:
interface IRental { ICustomer customer {get;set;} string Title { get; set; } decimal Cost{ get; set; } void Rent(); } What are the advantages/disadvantages of the approaches above? and is there a preferred way (one that is more scalable and maintainable).
IRental : ICustomer) then callingRent()ofIRentalimplies to me that you're renting something that is a customer.