R
Rob Thomas
Hi,
I'm just getting started with real OO design and programming and am
after a little advice.
Basically, I've got a Customer class and an Agency class. The Agency
class inherits all the properties and methods from Customer but I have
come accross a couple of problems:
I've got a Save, Add and Delete method in both of the objects. I'm going
on the assumption that it's a good idea to allow each object to control
itself. Each of these methods in the Agency class override the methods
in the Customer class and the base.Save etc methods are added to each of
the methods in the Agency class to fire off the assiciated method in the
Customer class before performing it's own Save etc.
I would like to pass in a database connection object to these classes
and force the Save methods to run in a transaction as there's no point
saving the Agency details without the Customer details. This is the area
that is causing me problems. I am currently passing the connection and
transaction objects directly into the Agency object via a constructor
and I then set relevant properties in the Customer object using
base.localDbConnection so that the Customer object has a connection to
work with. Bearing in mind that I am probably going to introduce
additional variants of Customer later, is this a good way of managing
the database connections etc ?
Any advice would be appreciated.
Rob
I'm just getting started with real OO design and programming and am
after a little advice.
Basically, I've got a Customer class and an Agency class. The Agency
class inherits all the properties and methods from Customer but I have
come accross a couple of problems:
I've got a Save, Add and Delete method in both of the objects. I'm going
on the assumption that it's a good idea to allow each object to control
itself. Each of these methods in the Agency class override the methods
in the Customer class and the base.Save etc methods are added to each of
the methods in the Agency class to fire off the assiciated method in the
Customer class before performing it's own Save etc.
I would like to pass in a database connection object to these classes
and force the Save methods to run in a transaction as there's no point
saving the Agency details without the Customer details. This is the area
that is causing me problems. I am currently passing the connection and
transaction objects directly into the Agency object via a constructor
and I then set relevant properties in the Customer object using
base.localDbConnection so that the Customer object has a connection to
work with. Bearing in mind that I am probably going to introduce
additional variants of Customer later, is this a good way of managing
the database connections etc ?
Any advice would be appreciated.
Rob