Is it any point to use inheritance in this scenario

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

Assume I have a store that have DVD movies and VHS movies and that customers
can rent any of the movies that the store have in stock.
In the Windows Form I use a readOnly DataGridView to represent the all the
movies that I have in stock.
I use a DataBase as a DataSource and here I use one database table called
Stck which store all the movies both DVDand VHS movies that I have in the
stock.

I use another DataGridView that is not readOnly when I want to add new
movies to the Stock.

Now to my question. Is it any point to use inheritance for the DVD and VHS
here because we can set up a inheritance hierarcy here. We can set an
abstract class like Product as the base class and derive the DVD movie class
and VHS movie class from this abstract Product class.

//Tony
 
Tony said:
Hello!

Assume I have a store that have DVD movies and VHS movies and that customers
can rent any of the movies that the store have in stock.
In the Windows Form I use a readOnly DataGridView to represent the all the
movies that I have in stock.
I use a DataBase as a DataSource and here I use one database table called
Stck which store all the movies both DVDand VHS movies that I have in the
stock.

I use another DataGridView that is not readOnly when I want to add new
movies to the Stock.

Now to my question. Is it any point to use inheritance for the DVD and VHS
here because we can set up a inheritance hierarcy here. We can set an
abstract class like Product as the base class and derive the DVD movie class
and VHS movie class from this abstract Product class.

//Tony


You certainly could do that. (And it might work best as an abstract class, or
it might not.) Try asking: "Does the application need to treat these two types
of movies differently?" If so, then inheritance is a very natural way to
specify precisely what is different about them and what is the same.

HTH,
-rick-
 
Rick Lones said:
You certainly could do that. (And it might work best as an abstract
class, or it might not.) Try asking: "Does the application need to treat
these two types of movies differently?" If so, then inheritance is a very
natural way to specify precisely what is different about them and what is
the same.

HTH,
-rick-

In the DataGridView I enter data directly into the dataGridView for Title,
RentBy, MovieID, Genre, HirePrice, Type and MovieDistributor but if I have
an inheritance how can I enter the data into the dataGridView then.

I hope you understand what I mean.

//Tony
 
Tony said:
In the DataGridView I enter data directly into the dataGridView for Title,
RentBy, MovieID, Genre, HirePrice, Type and MovieDistributor but if I have
an inheritance how can I enter the data into the dataGridView then.

I hope you understand what I mean.

//Tony

No, sorry. I don't see why the presentation details should have much to do with
defining the object hierarchy. I'm no DataGridView maven, but I would take for
granted that the DataGridView can be made to work either way. Possibly you
would need to write a bit of additonal code in one case or the other, but that
is not an issue that should drive the design, IMO.

-rick-
 
Assume I have a store that have DVD movies and VHS movies and that customers
can rent any of the movies that the store have in stock.
In the Windows Form I use a readOnly DataGridView to represent the all the
movies that I have in stock.
I use a DataBase as a DataSource and here I use one database table called
Stck which store all the movies both DVDand VHS movies that I have in the
stock.

I use another DataGridView that is not readOnly when I want to add new
movies to the Stock.

Now to my question. Is it any point to use inheritance for the DVD and VHS
here because we can set up a inheritance hierarcy here. We can set an
abstract class like Product as the base class and derive the DVD movie class
and VHS movie class from this abstract Product class.

Maybe.

Do you have a need for different members for the two?

Arne
 
Back
Top