Abstract class V/S interfaces, which is best for application

Hi Friends,

I have a question: if requirement in my project keep on changing daily or /weekly basis then what should be best to use in the application either Abstract class or Interfaces.If possible please elaborate with the help of example.

According to OOPs, interfaces are implicitly abstract, abstract class can have instance methods while interface is by default final. Abstract classes cannot be instantiated, but they can be subclassed whereas abstract methods in its parent class.Code snippet for interface

Hi,Its totally depends on your requirement, here are some of the points to be noted:1. If you are implementing a smaller functionality, use interfaces but use abstract class in case of larger applications. 2. If you want to implement a common functionality throughout the application, use an abstract class. It allows you to easily implement your class/functionality, whereas interface does not allow implementation.3. If you are implementing a functionality which will be useful across a whole application and to be compatible with large number of different-different types of objects, use interface. Abstract classes must be used for objects which are of same type.4. In abstract classes, just change the base class, change will be reflected in all inheriting classes automatically i.e. less code changes. Whereas in interfaces, you have to create a new interface each time.

Eg. of interfaces:

Cricketers who are also Sportsman's, so we can implement interfaces for them as follows:

public interface Cricketer{ Matches ODI(int iNoOfODIPlayed); }

public interface Sportsman{ Career Sports(string szTypeofSport); }

public interface CricketerSportsman extends Cricketer, Sportsman{...}

Eg. of abstract class:

Match is an abstract class, with Score() method. You can create ODI, T20, Test as its derived classed and call that method. Or you can make that method abstract and implement it inside each derived class.

My suggestion is Interfaces, if you want to keep changes the requirement frequently the best approach is interfaces.--------------------------------------------------------------------------------Give respect to your work, Instead of trying to impress your boss.