Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2005

Tip: Looking for answers? Try searching our database.

Object Orientation or Enumeration?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dwok - 19 May 2005 15:34 GMT
Hi All,

 I have a question that could be viewed as more of a general object
oriented question but I still thought this the best place to post it.

 I am developing a contact management application that makes use of
several custom classes such as "Contact, Phone_Number, eMail, Address".
I want to assign a Phone Number Type (Fax, Home, Cellular, etc..) to
each instance of the Phone_Number class. What I am not sure of is
whether I should use an enumeration within the "Phone_Number" class to
represent the various "types" of phone numbers or should I create a
separate class to represent the various "types" of phone numbers? When
I designed the database for my application I created a separate table
to hold the various "types" of phone numbers. I did this so I could add
new "phone number types" in the future.

 Am I "over emphasizing object oriented design" if I create a separate
class for "phone number types"? Would it be best to use an enumeration
and then update the code if I needed to add another "phone type" in the
future?

 Could anyone recommend a good book or reference that would cover
these aspects of object oriented design? Thanks!

- dwok
Carlos J. Quintero [.NET MVP] - 19 May 2005 17:11 GMT
If the phones have functionality (methods) and they work internally
differently or hold different pieces of data then you would use a PhoneBase
class and inherited XXXPhone classes. Otherwise an enum is enough.

Signature

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

> Hi All,
>
[quoted text clipped - 21 lines]
>
> - dwok
David Anton - 20 May 2005 16:19 GMT
Enums are just a nice shorthand for a class consisting only of integer
constants (in Java or J# that is exactly what you have to do), so if you're
sure that "phone number types" can always be encapsulated by integer
constants alone and never other types of fields or methods then enums are
just as object-oriented.

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter

> Hi All,
>
[quoted text clipped - 21 lines]
>
> - dwok

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.