When to use Interface?
When to use Interface?
518
27-Aug-2021
Aryan Kumar
24-Jun-2023Interfaces are a powerful tool in object-oriented programming that can be used to achieve a variety of goals. Here are some of the most common reasons to use an interface:
Here are some specific examples of when you might use an interface:
IShapethat defines the methods that all shapes must implement. This would make it clear to other developers what methods are available on shapes, and how to use them.Ultimately, the decision of whether or not to use an interface is a design decision that should be made on a case-by-case basis. However, the reasons listed above provide some general guidance on when interfaces can be a useful tool.