tags:

views:

41

answers:

0

Possible Duplicate:
Prefer composition over inheritance?

Say I have this class:

    public class ndata
{
    public int sal;
    public double cont;
    public string mytype;
}

I then have a choice of doing this:

    public class mydataTWO : ndata
{
    public string a;
    public DateTime d;
}

or I can do this:

    public class mydataONE 
{
    public string a;
    public DateTime d;
    public ndata aa= new ndata();
}

With the first option, (inheriting ndata), I can so something like this

        mydataTWO askTWO = new mydataTWO();
        askTWO.cont = 9.3; 

With the second option, (new instance of ndata), I can do something like this

        mydataONE askONE = new mydataONE();
        askONE.aa.cont = 9.3;

What are the implications/consequences of the two options from the point of view of:

  1. serialization (SOAP)
  2. readability
  3. ... other considerations I have not thought of?

Thanks for sharing your insight.