Skip to content

When to Use an Abstract Class vs. an Interface? #SHORTS

When to Use an Abstract Class vs. an Interface? #SHORTS

It’s critical to know when to use an interface vs. an abstract class to prevent creating the wrong abstractions down the road.

Abstractions let us define the properties and behaviours that future objects need to conform to. They help us:
1. Decouple components
2. Create a contract

Both of these capabilities are super important for testing.

Use interfaces by default but use abstract classes if you also need to define some common behavior for subclasses.

#SHORTS

Cursuri interesante:

Leave a Reply

Your email address will not be published. Required fields are marked *