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

preview_player
Показать описание
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
Рекомендации по теме
Комментарии
Автор

Abstract class is like a super class but with the ability to define just the method signature and not have to provide the default implementation if you don't want to.

BRBallin
Автор

Thanks,
I recently knew that in typescript a abstract class can be implmented instead of being extended

DJLarox
Автор

Thank you for explaining absolutely nothing

kirim