user278618
user278618

Reputation: 20242

Basic question about interface

I get answer in:

Object modelling problem

that I should use interface instead class Extra in this case:

public Extra
{
public bool Paid {get;set;}
public string Name {get;set;}
public string Code {get;set;}
}

class Car
{
private List<Extra> _listOfExtras=new List<Extra>

public List<Extra> ListOfExtras
{
...
}
}

I don't understand why it is better solution

Upvotes: 0

Views: 114

Answers (1)

Stefan Steinegger
Stefan Steinegger

Reputation: 64628

It really depends of the specific requirements and technical constraints. You can't expect any good advise here, because we all can just guess what you are doing with this classes.

For instance. As long as the Extra class consists of only these three values, I don't know why it should be an interface. It could be designed as a value object.

Upvotes: 1

Related Questions