Results 1 to 13 of 13

Thread: a question of granularity

  1. #1
    Member
    Join Date
    Jan 03
    Location
    Beer City
    Posts
    33

    a question of granularity

    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
    its called the "F1" key-- use it

  2. #2
    Fanatic Member
    Join Date
    Oct 00
    Location
    Reading, UK
    Posts
    870
    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!)
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  3. #3
    Member
    Join Date
    Jan 03
    Location
    Beer City
    Posts
    33
    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
    its called the "F1" key-- use it

  4. #4
    Fanatic Member
    Join Date
    Oct 00
    Location
    Reading, UK
    Posts
    870
    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!!!!
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  5. #5
    Member
    Join Date
    Jan 03
    Location
    Beer City
    Posts
    33
    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
    its called the "F1" key-- use it

  6. #6
    Fanatic Member
    Join Date
    Oct 00
    Location
    Reading, UK
    Posts
    870
    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....
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  7. #7
    Member
    Join Date
    Jan 03
    Location
    Beer City
    Posts
    33
    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
    its called the "F1" key-- use it

  8. #8
    Fanatic Member
    Join Date
    Oct 00
    Location
    Reading, UK
    Posts
    870
    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!
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  9. #9
    Member
    Join Date
    Jan 03
    Location
    Beer City
    Posts
    33
    Yah yah yah.....
    anyone else have any thoughts... I am losing this one alone.


    tal
    its called the "F1" key-- use it

  10. #10
    Lively Member
    Join Date
    Feb 03
    Location
    UK
    Posts
    95
    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.

  11. #11
    Member
    Join Date
    Jan 03
    Location
    Beer City
    Posts
    33
    Woohoo one vote for me!!
    its called the "F1" key-- use it

  12. #12
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 02
    Location
    Washington St.
    Posts
    2,464
    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.

  13. #13
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 03
    Posts
    681
    I would third it - if that is possible

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •