User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Software Developers' Lounge section within the Software Development category of DaniWeb, a massive community of 456,528 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,803 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Software Developers' Lounge advertiser: Programming Forums
Views: 760 | Replies: 2
Reply
Join Date: Aug 2006
Posts: 5
Reputation: chrisw09 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
chrisw09 chrisw09 is offline Offline
Newbie Poster

Object Best Practices

  #1  
Oct 1st, 2007
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2006
Posts: 162
Reputation: Cerberus is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 14
Cerberus Cerberus is offline Offline
Junior Poster

Re: Object Best Practices

  #2  
Oct 3rd, 2007
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.
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 3,090
Reputation: Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold 
Rep Power: 15
Solved Threads: 307
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Posting Sensei

Re: Object Best Practices

  #3  
Oct 3rd, 2007
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.
Last edited by Ezzaral : Oct 3rd, 2007 at 6:45 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Software Developers' Lounge Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Software Developers' Lounge Forum

All times are GMT -4. The time now is 4:17 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC