Design question

  • Thread starter Thread starter R.Balaji
  • Start date Start date
R

R.Balaji

Hi,

I am designing webservice component.

I am defining a class for the entity user.

UserId, UserName will be frequently used.
I have created a class for them

class UserHeader
{
public string userId;
public string userName;

public bool ValidateUserHeader();
}

All other user details are captured in another class. This will be rarely
used.

class UserDetail
{
public string userEmail;
public string userAddress;
pubilc string userCity;

public bool ValidateUserDetail();
}

I capture the user photo and his biodata document in another class

class UserBinary
{
byte[] biodata;
byter[] photo;


}


If I represent User class comprising of all the three classes like

class User
{
UserHeader uh;
UserDetail ud;
UserBinary ub;
}

Is this a correct approach?

I really want to create User class inheriting from all three classes.
But C# does not support multiple inheritances?
All this sub classes cannot be converted into interfaces also as it has the
data members.

Is there any better idea?


Regards,
R.Balaji
 
There's no multiple inheritance, but I don't see that as your problem.
You're thinking of your classes as data, not classes. But FWIW, you can
create nested classes (or structs) that are somewhat akin to C++ friend
classes.
 
Back
Top