Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 12th, 2007, 06:05 AM
Registered User
 
Join Date: Apr 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default class design

I have some set of classes and each of them have some common members,say..

class1

 aID as integer
 aName as string

class2
  bID as integer
  bName as string

class3

   aID as integer
   bID as integer
   cSize as integer
   --------

So what's an ideal solution to design the architecture whether i have to use some interface or abstract class to achieve common properties or something....

  #2 (permalink)  
Old April 12th, 2007, 08:59 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Determine what the common members are of each class, and create a super class containing those members. Then derived each subclass from it.

If in your example "aID" and "bID" are actually the same thing, you could place those in the super class. However, in your "class3" you have 2 "..ID" members. That doesn't support the idea that the previous to ".ID" members are the same thing. Perhaps if you explain a bit more about what the specific classes and their members are we can help further. The names you are using are fairly vague.

-Peter
  #3 (permalink)  
Old April 13th, 2007, 12:15 AM
Registered User
 
Join Date: Apr 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your comments .These are my classes

Public Class sport
    Private _sportsId As Integer
    Private _sportsName As String
    Public Property SportsId() As Integer
     -----------
    End Property
    Public Property SportsName() As String
     --------------
    End Property
End Class

========================================

Public Class Equipment
    Private _eqptId As Integer
    Private _eqptName As String
    Public Property EqpmtId() As Integer
        -----------
    End Property
    Public Property EqpmtName() As String
        -----------
End Class
=========================================

Public Class EquipmentFitt
    Private _eqptId As Integer
        Private _sportsId As Integer
        Private _eqpSize As Integer
        Private _eqpFitting As Integer
        Private _sportID As Integer

        Public Property SportsID() As Integer
         -----------
        End Property

        Public Property EquipmentID() As Integer
            ---------
        End Property
        Public Property EquipmentSize() As Integer
         -----------
        End Property
        Public Property EquipmentFitting() As Integer
         -----------
        End Property
             Public Property AthleteID() As Integer
            ---------
        End Property
    End Class

These are business objects just want to hold the data..How the design has to go for getting the common members,I am using vb.net
  #4 (permalink)  
Old April 13th, 2007, 07:59 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You might consider object composition where it's appropriate. Here's an example:

Public Class EquipmentFitt

   Private _objSport As sport
   Private _objEquipment As Equipment

   Public Property Sport As sport
      ....
   End Property

   Public Property Equipment As Equipment
      ....
   End Property

   'Add additional internals and properties to further define this EquipmentFitt

End Class

-Peter


Similar Threads
Thread Thread Starter Forum Replies Last Post
Design patterns for web design ceadge HTML Code Clinic 0 June 19th, 2006 11:26 AM
C# Class Design Handbook dchernin All Other Wrox Books 9 December 20th, 2004 09:02 AM
Java Design issue with UML and Design Patterns the_logical_way Apache Tomcat 0 May 31st, 2004 04:02 AM
Design decision on class library projects? tkubaska BOOK: ASP.NET Website Programming Problem-Design-Solution 2 May 19th, 2004 11:43 AM
Class Design Info... kaizer BOOK: Beginning Java 2 1 December 27th, 2003 06:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.