"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..
tshad <tf*@dslextreme.comwrote:
>I am starting to work with abstract Classes and Interface in VS 2003 and
was wondering which is the best way to set the files up.
If I have something like:
abstract user class (could also just be a class that would be the base
class)
employee inheriting user class
applicant inheriting user class
interface something
Is it best to have:
user.cs
employee.cs
applicant.cs
something.cs
or
have them all in the same file, such as:
user.cs
In my experience, it's *much* better to have one top-level type per
file. The one exception I sometimes have to this is delegates, which I
sometimes lump together in Delegates.cs.
So for this:
************************************
public abstract class Plane
{
public string tailNumber;
protected int _numberOfEngines;
public int numberOfWheels = 3;
public int NumberOfEngines
{
get
{
return _numberOfEngines;
}
set
{
_numberOfEngines = value;
}
}
public string TailNumber
{
get
{
return tailNumber;
}
set
{
tailNumber = value;
}
}
}
public class SingleEnginePlane : Plane
{
public SingleEnginePlane()
{
_numberOfEngines = 1;
}
}
public class DoubleEnginePlane : Plane
{
public DoubleEnginePlane()
{
_numberOfEngines = 2;
}
}
***********************************************
You would have 3 files:
plane.cs
SingleEnginePlane.cs
DoubleEnginePlane.cs
Thanks,
Tom
>
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too