Directory Freebies VS CheatSheet Forum

RSS

Email

Translate

Home About Archive Privacy Contact Advertise Write for Dev102
Posted by Shahar Y on Jul 24th, 2008 | Filed under .Net, C#, Visual Studio | 2 Comments

Sometimes we are using the same patterns of code over and over again. Those of us who are lazy (but smart) will create their own code snippets, if you are not familiar with this subject, read about how to create code snippets easily. But what if we need to create lots of classes with the same pattern? Code snippets may not be enough because they lack of some functionality which is needed to achieve our goal. Consider the following code:

abstract class FourWheelsVehicle : IVehicle
{
    abstract public double MaxVelocity { get; }

    abstract public string Manufacturer { get; }

    abstract public double Price { get; }

    abstract public int YearManufactured { get; }

    virtual public int NumberOfWheels
    {
        get { return 4; }
    }
}

An abstract class called FourWheelsVehicle implements the IVehicle interface (which is not presented here because it is not important for our matter). Our task is to create classes which represent each and every existing 4 wheels vehicle, there is a lot of work to do, a huge amount of work. So, I started by implementing Mazda6 class:


Continue Reading...
Write Article for Dev102

Write for Dev102!

We pay for user submitted tutorials and articles that we publish. Anyone can send in a contribution

Learn More