0

Lets say I have an object called Customer. It has general info like name,address,phone,email. I use it throughout my application. Now, I have a new piece of code to add that will use a couple of arguements in Customer and will need a new arguement, lets call it "salesytd".

Here's my dilema:
- I'm lazy
- I'm anal retentive.

With that said should I:
1) Add the arguement, getter and setter to Customer and only use what i need.
2) Extend Customer with a new class and only use what i need.
3) Create a new class for only what i need.
4) Do something else
5) Give up and start drinking

Thanks

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by Ezzaral
0

If the new class uses some of the methods in the Customer class and is a type of customer then i would say extend/inherit the Customer class.

Best practice would probably be to identify common functionality in the design and create a class from which all relevant classes can inherit.

0

It really depends on how that piece of info relates to Customer. Is it specific to each customer and applicable to all customers? Then add it.

Is it only applicable to a certain kind of customer and has no meaning in the context of most customers? Then extend Customer.

Is it unrelated to innate Customer attributes but requires some data from Customer and it's just a convenient place to "stick" that piece of info? It should be in some other class and pull the info as needed from a Customer that is passed in as a parameter.

That's about the only general advice I could give without knowing more specifics of the relationships.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.