When we have to use abstract and when we have to use interface ?
-
Hi , When we have to use abstract and when we have to use interface in real time coding Thanks in advance Azeez.
Interface is lightweight than Abstract....
**Abstract** When you don't clear about the future expansion of the framework... For creating multiple version application.. For creating products... For putting common behavior so that drived classes can use it without writing code again & again...
**Interface** For defining rules and business policies... To enforce something.... to overcome the problem of multiple inhetitence
-
Hi , When we have to use abstract and when we have to use interface in real time coding Thanks in advance Azeez.
You never have to use either. When defining a group of similar classes you may find it beneficial to define an interface (or more than one) that specifies what things the classes have in common. If there is some common code that the classes should share, you may want to put that code in a base class. If that base class itself should not be instantiated, then you may want to mark it as abstract. In the long run, you probably should always define an interface whenever you define a base class.