Added a few lines to emphasize Interfaces importance to Design patterns. (#23700)
* Added a few lines to emphasize Interfaces importance to Design patterns. * Fixed several grammatical mistakes
This commit is contained in:
committed by
Manish Giri
parent
7eb767860a
commit
7498ce0052
@ -26,8 +26,9 @@ An Interface can not :
|
|||||||
* Be instantiated.
|
* Be instantiated.
|
||||||
---
|
---
|
||||||
|
|
||||||
Using interfaces allows us to change our implementation in our project without breaking other parts,
|
Using interfaces allows us to change our implementation in our project without breaking other parts, and only have to change the one place where the object is created.
|
||||||
and only have to change the one place where the object is created.
|
|
||||||
|
As interfaces do not implement any logic by themselves, they are a great tool for programmers to program against a type rather than a concrete object. This is very useful in keeping code loosely coupled. This behavior of interfaces made them imperative for implementation of Design Patterns.
|
||||||
|
|
||||||
Interface Example:
|
Interface Example:
|
||||||
```csharp
|
```csharp
|
||||||
@ -38,6 +39,7 @@ public Interface IUserFavoriteFood
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
---
|
---
|
||||||
|
|
||||||
Interface inheritance and implementation:
|
Interface inheritance and implementation:
|
||||||
```csharp
|
```csharp
|
||||||
public class UserHungry : IUserFavoriteFood
|
public class UserHungry : IUserFavoriteFood
|
||||||
|
Reference in New Issue
Block a user