Hi guys,
I'm quite new to this .NET (C#) lark but I'm wondering if you can advise me on my class design options below:
I have a system which has 'Customers' and 'Clients' in the database.
Each has its own table in the db and I've also created a single generic 'Address' table to store address info for either of the two.
Now, in my code I have created a class for Customers and its all good. I can create, load and save customers via it.
The next step is to create an Address class and this is where I'm after advice. Do I:
a) Create a stand alone Address class, just like the Customer one and access all its variables and functions (i.e. save address) via the Customer class?
b) Create Address as an 'abstract' class which Customers can be derived from which I'm assuming will give Customers full access to its variables and keep methods (i.e. Save Address) in the abstract class (can I do that?).
c) Do as (b) but have the methods in the candidate class. The only thing I thought with this is that I would have to copy the same methods over to anything else that uses them such as Clients....shouldn;t it be kept in one place?
Anyway - I think I just need to get my head around the best way of using inheritance on this one! Any advice is welcomed!!
I'm quite new to this .NET (C#) lark but I'm wondering if you can advise me on my class design options below:
I have a system which has 'Customers' and 'Clients' in the database.
Each has its own table in the db and I've also created a single generic 'Address' table to store address info for either of the two.
Now, in my code I have created a class for Customers and its all good. I can create, load and save customers via it.
The next step is to create an Address class and this is where I'm after advice. Do I:
a) Create a stand alone Address class, just like the Customer one and access all its variables and functions (i.e. save address) via the Customer class?
b) Create Address as an 'abstract' class which Customers can be derived from which I'm assuming will give Customers full access to its variables and keep methods (i.e. Save Address) in the abstract class (can I do that?).
c) Do as (b) but have the methods in the candidate class. The only thing I thought with this is that I would have to copy the same methods over to anything else that uses them such as Clients....shouldn;t it be kept in one place?
Anyway - I think I just need to get my head around the best way of using inheritance on this one! Any advice is welcomed!!