Arne Vajhøj said:
Let us take your example.
Let us say that we consider Film class with two subclasses
DVD and BR.
The question is: will the DVD and BR class have any specific
functionality?
If not then drop them.
Note that whether there are specific functionality may
depend on the context.
For a store selling films there may be no difference in
functionality but for a factory producing them there may
be a difference.
Arne
Just recap the multimedia store is about to use this functionalitty which is
selling/leasing music albums and film
I have three design alternatives for inheritance.
1.My first alternative. An abstract class Product that is most general and
below this I have Film and Music also abstract and below Film I have DVD and
below Music I have CD.
2.Your altetrnative
IProduct interface
- Music and Film classes implementing IProduct
- Music class has a property MediaType that can contain enum value
MusicMediaType.CD
- Film class has a property MediaType that can contain enum value
FilmMediaType.DVD
be better?
3.The same as 1 but in addition let Product implement interface IProduct
My first question is:
If I ask you which of these three alternatives should you use ?
I hope that you can give some motivation to your choice ?
If I ask myself if Film and Music will any specific functionality?
My second question is:
What does that mean actually ?
a. I mean you can buy both a DVD and a CD
b. You can lend a DVD and a CD back to the store after you have hired it.
The multimedia store might allow you to reserve.
c. So in that case you can reserve a DVD and a CD.
In all these three cases a,b and c it's the same with a CD and DVD.
But there is one specific difference and that is a DVD that you hire or buy
has only one movie but
if you buy or hire a CD there are many tracks on that CD.
Another difference is that a CD doesn't have genre like action, thriller,
drama and so on.
A third difference is the format of the film on a DVD and the format of the
tracks on a CD.
I track for music might have MP3 format.
My third question:
I have hard to see that anything should be placed in the concrete class CD
and DVD all data example that I found like
format, title, producer, name, playtime, buyprice, hireprice, number of
tracks on CD can be placed in Music or Film but in that case my CD and DVD
will be empty of data and that seems strange.
So can you give a single example of some data that is suitable to be placed
in the concrete class CD and DVD.
//Tony