Results 1 to 7 of 7

Thread: Structuring Properties???

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Posts
    13

    Structuring Properties???

    I am writing some large classes that have alot of properties that could be catorgized

    eg.)

    Person
    >FirstName
    >LastName
    >Address
    >>Postalcode
    >>pobox
    >>Street
    >>Apartment

    this is just an example my class is not as simple as this :

    They way i was thinking of doing this is nested classes:

    VB Code:
    1. Class Person
    2.  
    3.     Class Address
    4.           Public Property Street() as String
    5.             'whatever>
    6.            End Property
    7.      End Class
    8.  
    9. End Class

  2. #2
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    Why not make Address a stand alone class so that it can be reused outside of Person, for say Building.

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    lol , what's your question ?

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Posts
    13
    I wanted to know if this is the proper way of doing it.

  5. #5
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Do what VBCrazyCoder said. Make each class separate and use inheritance.

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    If these obje have any relation to each other then put them in one class , this class contains the obj and their properties .

  7. #7
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Originally posted by Pirate
    If these obje have any relation to each other then put them in one class , this class contains the obj and their properties .
    I am not sure I understand you correctly, but I think you are saying that if they have a relationship, they should be in the same class. That would be bad OO programming if you did that. Person should be a class that is seperate from the Address class. Then, the person object can expose a Address object as a property, and so could any other object that could possibly have an address associated with it. For example, Building, as mentioned above, has a physical address. Or how about a piece of equipment you are keeping track of where it is at, it should have an Address associated with it also.

Posting Permissions

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



Click Here to Expand Forum to Full Width