Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My two cents:</p> <p>An interface basically defines a contract, that any implementing class must adhere to(implement the interface members). It does not contain any code.</p> <p>On the other hand, an abstract class can contain code, and there might be some methods marked as abstract which an inheriting class must implement.</p> <p>The rare situations I've used abstract classes is when i have some default functionality that the inheriting class might not be interesting in overriding, in say an abstract base class, that some specialized classes inherit from.</p> <p>Example(a very rudimentary one!):Consider a base class called Customer which has abstract methods like <code>CalculatePayment()</code>, <code>CalculateRewardPoints()</code> and some non-abstract methods like <code>GetName()</code>, <code>SavePaymentDetails()</code>. </p> <p>Specialized classes like <code>RegularCustomer</code> and <code>GoldCustomer</code> will inherit from the <code>Customer</code> base class and implement their own <code>CalculatePayment()</code> and <code>CalculateRewardPoints()</code> method logic, but re-use the <code>GetName()</code> and <code>SavePaymentDetails()</code> methods.</p> <p>You can add more functionality to an abstract class(non abstract methods that is) without affecting child classes which were using an older version. Whereas adding methods to an interface would affect all classes implementing it as they would now need to implement the newly added interface members.</p> <p>An abstract class with all abstract members would be similar to an interface.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload