What do I need to consider to determine which design I choose when I have the following scenario?
There are two cases to considerer;
- Given T a generic class, I have to do something with multiple T's (Iterating each one of them).
- In other cases, with the same T, I have to process just once.
In both cases, independent of what is T and how I'll need to process it, the class that comprises T will behave exactly the same way, therefore, I don't need to worry about implementation details.
There are 2 possible solutions, and I don't know what directions should I follow to decide between them.
- Always consider as a List, this is for sake of simplicity, since there are no difference between a List of T and only T.
- Use inheritance; the first child class will receive a List of T and work with it, the second, a single T and work with it.
Are there some good pratices or some article to help to decide such cases? I'm looking for something like this article, or your experience as well.
The class I'm design is not T, but its composer.