Higher Class Hierarchy vs Wider Class Spectrum

68 views Asked by At

I have a "Good Practice" Question:

Lets assume a case where one have many List Types

  1. IObservableList With Events

  2. IReadOnlyList Read Only

  3. ISomeList Some List that perform additional operations

Is it better to define 6 classes Like

  1. ObservableList:IList

  2. ObservableReadonlyList:IList

  3. ObservableSomeList:IList

  4. ReadonlyList:IList

  5. ReadonlySomeList:IList

  6. ObservableReadonlySomeList:IList

or

Adapting one too another using 3 Classes:

  1. ReadOnlyListAdapter : IList

  2. ObservableListAdapter : IList

  3. SomeListAdapter : IList

and instanciating with

IList MyObservableReadonlySomeList = new ReadonlyListAdapter(new ObservableListAdapter(new SomeListAdapter)));

Note:

i tend to like the 6 classes better, but what goes when there are 6 or 7 properties for a class??? 30-50 classes?

Thank you, have a nice day...

1

There are 1 answers

1
Don Roby On BEST ANSWER

i tend to like the 6 classes better, but what goes when there are 6 or 7 properties for a class??? 30-50 classes?

You might want to look at the Decorator pattern. It may indeed be what you're actually doing with what you're calling adapters.