Base Classes or Interfaces

Problem
You want to know when to use base classes versus interfaces.

Solution
When defining a set of methods that a group of types should expose, prefer abstract base classes to interfaces.

Discussion
An interface can be a better option if you’re writing an application that uses .NET remoting; otherwise, favor abstract base classes. You can extend a base class with new methods and properties without breaking existing clients. Also, members in an abstract class can have a default implementation. This reduces the amount of code required when inheriting from the base class.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s