Object Orientation or Enumeration?

  • Thread starter Thread starter dwok
  • Start date Start date
D

dwok

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
 
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.

--

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
 
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
 
Back
Top