Derive abstract class from non-abstract class

Posted by Jehof on Stack Overflow See other posts from Stack Overflow or by Jehof
Published on 2010-04-08T19:12:56Z Indexed on 2010/04/08 19:23 UTC
Read the original article Hit count: 504

Filed under:
|

Is it OK to derive an abstract class from a non-abstract class or is there something wrong with this approach?

Here´s a little example:

public class Task {
  // Some Members
}

public abstract class PeriodicalTask : Task {
  // Represents a base class for task that has to be done periodicaly.
  // Some additional Members
}

public class DailyTask : PeriodicalTask {
  // Represents a Task that has to be done daily.
  // Some additional Members
}

public class WeeklyTask : PeriodicalTask {
  // Represents a Task that has to be done weekly.
  // Some additional Members
}

In the example above i do not want to make the class Task abstract, because i want to instantiate it directly. PeriodicalTask should inherit the functionality from Task and add some additional members but i do not want to instantiate it directly. Only derived class of PeriodicalTask should be instantiated.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET