Activity Forums Salesforce® Discussions What is the use of interfaces(in apex classes)? Reply To: What is the use of interfaces(in apex classes)?

  • Parul

    Member
    September 22, 2018 at 12:45 pm

    Hi

    Reasons to use an interface:

    Behavior Contract - A common method is needed on otherwise unrelated objects. The implementation of that method could be significantly different. As such, there is little benefit in inheriting the implementation (behavior).
    Coupling - If code is only dependent on the interface then it is easier to change the implementation, as there no/fewer references to a specific class. E.g. I can change the way a plane flys without any risk of making birds fall out of the sky.

     

    Thanks