PDA

Click to See Complete Forum and Search --> : a question of granularity


Tal McMahon
May 23rd, 2003, 10:11 AM
Hello all,
a co worker ad I are having a Philosophical debate about how far to carry granularity in application design. Any thoughts would be appreciated.

Here is a scenario:

If we are making an application that tracks Employees within a company, we are in agreement that we could/should have a class called employee that defines employee information. The thoght is then we can always make a collection of employees that would then be a department.

In defining the Employee Data we have come to realize that we should probobly inherit from a class called Person as all employees are people and then we can also use our person class in the future for an Applicant tracking database. All is well. Now for the debate.

Should We make a base class called person that contains person type information and does all of the validating for name , address, social security etc.

OR


should we go farther and makebase classes for things like Address, Name, Social Security and then include those in the class person, and then in the employee etc.


Please add any thoughts or comments there are a few fermented malt beverages invoved on this one.


Tal McMahon

nswan
May 23rd, 2003, 10:31 AM
if it's going to a vote i would do the first one. You can over complicate these kind of things some times, and you'll spend more time developing little classes when you could spend it doing more worthwhile things (such as drinking beer!)

Tal McMahon
May 23rd, 2003, 10:37 AM
hmm.... my buddy is allready listing the beers I will have to buy.

My thought is that you can make Many Classes just as you would make many tables in your database.


if I make a Social Security number class, then as I build more applications I can draw from that class. My buddy says thats what "copy and paste" is for.

To Which I counter What if the Social security number format were to change and add a 3rd digit in the middle 2. if you have copied and pasted validation ten times, You have 10 applications that need to be addressed. My way you have one base class.

the debate continues....


tal

nswan
May 23rd, 2003, 10:40 AM
you would only need the validation code for the security number in the person class once though wouldn't you?
Just make sure you have things in the base person class that every person that could ever exist would have!

ps i wouldn't base your argument result on my thoughts alone. I'm sure someone will soon come along that will totally disagree with me!!!!

Tal McMahon
May 23rd, 2003, 10:45 AM
I would agree with you in that if there was only one place that a piece of data was used. as for Social Security number, you may be right. But maybe the Address is a better example. there are many things that have Addresses not just people.

as for the debate being settled....we have a week before the determination is made.



tal

nswan
May 23rd, 2003, 10:48 AM
i see what you are getting at.

the best thing you could do for that is have a validation class. This class would do validation for addresses for people, for places, for companies etc....

Tal McMahon
May 23rd, 2003, 10:51 AM
Right, I am a Database geek, I like to break everything into little bits and then put them together as I need like tinker toys. :)

Thats how our debate began, and now your involved...
I Want to make a class for Phone numbers, and Address then include them in a larger class Person.

in actuality, I prolly could have done that all in the time I have spent Chatting here. but I like to go that extra mile...lol

tal

nswan
May 23rd, 2003, 10:54 AM
well there's always more than one way to do things and they are usually all correct ways so it's just down to personal preference and the way you have done things in the past or have been taught.

i would agree with your colleague though!

Tal McMahon
May 23rd, 2003, 10:58 AM
Yah yah yah..... :)
anyone else have any thoughts... I am losing this one alone.


tal

shutty
May 27th, 2003, 04:08 AM
If you think the potential component (i.e. Address , social security number etc) is reusable, then strictly speaking it should be in a class of it's own. I tend to make anything that has it's own data format and validation rules (social security number!) a class. That way I know when I want to use it again I have all the code associated with it in one place.

Copy'n'Paste is not reuse! - if you make a copy then you are making a new 'different' piece of maintainable code. Like you said below, if you want to change that functionality in the future you have to change and test it everywhere it is used.

Tal McMahon
May 27th, 2003, 08:50 AM
Woohoo one vote for me!!

hellswraith
May 27th, 2003, 03:45 PM
I will second this:
Copy'n'Paste is not reuse! - if you make a copy then you are making a new 'different' piece of maintainable code. Like you said below, if you want to change that functionality in the future you have to change and test it everywhere it is used.

VBCrazyCoder
May 27th, 2003, 04:59 PM
I would third it - if that is possible :D