Skip to content

Commit afef665

Browse files
authored
Merge pull request #49242 from wwlpublish/4333daa99459f1d6e5fef3951daa7f652695e0a6b2a70ab58d437cf33e2425d2-live
Modules/M03-design-resilient-code-interfaces
2 parents 54851c5 + 2d272e0 commit afef665

13 files changed

+55
-34
lines changed

learn-pr/wwl-azure/design-resilient-code-interfaces/1-introduction.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Introduction
44
metadata:
55
title: Introduction
66
description: "Introduction to designing resilient code with interfaces in C#."
7-
ms.date: 02/14/2025
7+
ms.date: 02/17/2025
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 2
1214
content: |
1315
[!include[](includes/1-introduction.md)]

learn-pr/wwl-azure/design-resilient-code-interfaces/2-examine-interface-designs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Examine interface designs
44
metadata:
55
title: Examine interface designs
66
description: "Examine interface designs and SOLID design principles."
7-
ms.date: 02/14/2025
7+
ms.date: 02/17/2025
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 5
1214
content: |
1315
[!include[](includes/2-examine-interface-designs.md)]

learn-pr/wwl-azure/design-resilient-code-interfaces/3-implement-explicit-interface-members.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Implement explicit interface members in a class
44
metadata:
55
title: Implement explicit interface members in a class
66
description: "Implement explicit interface members in a class using C#."
7-
ms.date: 02/14/2025
7+
ms.date: 02/17/2025
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 6
1214
content: |
1315
[!include[](includes/3-implement-explicit-interface-members.md)]

learn-pr/wwl-azure/design-resilient-code-interfaces/4-use-combine-multiple-interfaces.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Use and combine multiple interfaces
44
metadata:
55
title: Use and combine multiple interfaces
66
description: "Use and combine multiple interfaces in your C# classes."
7-
ms.date: 02/14/2025
7+
ms.date: 02/17/2025
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 5
1214
content: |
1315
[!include[](includes/4-use-combine-multiple-interfaces.md)]

learn-pr/wwl-azure/design-resilient-code-interfaces/5-understand-tightly-coupled-code.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Understand tightly coupled code
44
metadata:
55
title: Understand tightly coupled code
66
description: "Discover how tightly coupled code impacts the maintainability applications."
7-
ms.date: 02/14/2025
7+
ms.date: 02/17/2025
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 5
1214
content: |
1315
[!include[](includes/5-understand-tightly-coupled-code.md)]

learn-pr/wwl-azure/design-resilient-code-interfaces/6-refactor-use-interfaces.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Refactor using interfaces
44
metadata:
55
title: Refactor using interfaces
66
description: "Use interfaces in refactoring to reduce dependencies."
7-
ms.date: 02/14/2025
7+
ms.date: 02/17/2025
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 6
1214
content: |
1315
[!include[](includes/6-refactor-use-interfaces.md)]

learn-pr/wwl-azure/design-resilient-code-interfaces/7-exercise-decouple-code-with-interfaces.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: 'Exercise: Decouple code with interfaces'
44
metadata:
55
title: 'Exercise: Decouple code with interfaces'
66
description: "Exercise: Decouple code with interfaces in C# code."
7-
ms.date: 02/14/2025
7+
ms.date: 02/17/2025
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 25
1214
content: |
1315
[!include[](includes/7-exercise-decouple-code-with-interfaces.md)]

learn-pr/wwl-azure/design-resilient-code-interfaces/8-knowledge-check.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Knowledge check
44
metadata:
55
title: Knowledge check
66
description: "Knowledge check"
7-
ms.date: 02/14/2025
7+
ms.date: 02/17/2025
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 2
1214
content: |
1315
[!include[](includes/8-knowledge-check.md)]
@@ -21,7 +23,7 @@ quiz:
2123
explanation: "Correct. Explicit interface members are only accessible through the interface instance, so you need to cast the class instance to the interface type."
2224
- content: "By using the `this` keyword within the class."
2325
isCorrect: false
24-
explanation: "Incorrect. Explicit interface members cannot be accessed using the `this` keyword within the class; they are only accessible through the interface instance."
26+
explanation: "Incorrect. Explicit interface members can't be accessed using the `this` keyword within the class; they're only accessible through the interface instance."
2527
- content: "By using reflection to invoke the members."
2628
isCorrect: false
2729
explanation: "Incorrect. While reflection can be used to invoke members, it is not the standard way to access explicit interface members. The correct approach is to cast the class instance to the interface type."

learn-pr/wwl-azure/design-resilient-code-interfaces/9-summary.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Summary
44
metadata:
55
title: Summary
66
description: "Summary."
7-
ms.date: 02/14/2025
7+
ms.date: 02/17/2025
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 2
1214
content: |
1315
[!include[](includes/9-summary.md)]

learn-pr/wwl-azure/design-resilient-code-interfaces/includes/3-implement-explicit-interface-members.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
In C#, explicit interface implementation allows a class to implement interface members in a way that they are only accessible through the interface, not the class instance. This is particularly useful when a class implements multiple interfaces with members that have the same signature.
1+
In C#, explicit interface implementation allows a class to implement interface members in a way that they're only accessible through the interface, not the class instance. This is useful when a class implements multiple interfaces with members that have the same signature.
22

33
## Multiple interfaces in a class
44

5-
A class in C# can implement multiple interfaces, allowing it to inherit behavior from various sources. This capability is crucial because C# does not support multiple inheritance of classes. By implementing multiple interfaces, a class can provide different functionalities and ensure that it adheres to the contracts defined by those interfaces.
5+
A class in C# can implement multiple interfaces, allowing it to inherit behavior from various sources. The ability to combine multiple interfaces is crucial because C# doesn't support multiple inheritance of classes. Implementing multiple interfaces allows a class to have different features and ensures it follows the rules set by those interfaces.
66

77
- Interfaces define a group of related functionalities.
88
- A class or struct must implement all members of the interfaces it inherits.
@@ -28,7 +28,7 @@ public interface IMetricDimensions
2828

2929
In C#, a class can inherit from only one class but can implement multiple interfaces. This is especially important when several interfaces have the same member names. To avoid confusion, we use explicit interface implementation.
3030

31-
Explicit interface implementation ensures that each member of an interface has a unique implementation, preventing conflicts. It also clarifies which interface a member belongs to when a class implements two or more interfaces with the same member names. This allows a class to fulfill the requirements of multiple interfaces, providing diverse functionalities.
31+
Explicit interface implementation ensures that each member of an interface has a unique implementation, preventing conflicts. It also clarifies which interface a member belongs to when a class implements two or more interfaces with the same member names. Explicit interface implementation allows a class to fulfill the requirements of multiple interfaces, providing diverse functionalities.
3232

3333
To explicitly implement a member of an interface, you add the interface name and a period before the member name. Here's an example:
3434

@@ -64,7 +64,7 @@ In this code, the `Box` class is implementing two interfaces: `IEnglishDimension
6464
6565
## Use explicit interface members
6666

67-
To execute and test code that utilizes explicit interface members, you need to create instances of the interfaces and call their members. This ensures that the correct implementation is invoked based on the interface type.
67+
You need to create instances of the interfaces and call their members to execute and test code that utilizes explicit interface members. This ensures that the correct implementation is invoked based on the interface type.
6868

6969
```csharp
7070
Box box = new Box();
@@ -77,7 +77,7 @@ Console.WriteLine($"Length in centimeters: {mDimensions.Length()}");
7777
Console.WriteLine($"Width in centimeters: {mDimensions.Width()}");
7878
```
7979

80-
In this example, the `Box` class instance is cast to both `IEnglishDimensions` and `IMetricDimensions` to access the explicit interface members. The output will display the dimensions in both English and metric units.
80+
In this example, the `Box` class instance is cast to both `IEnglishDimensions` and `IMetricDimensions` to access the explicit interface members. The output displays the dimensions in both English and metric units.
8181

8282
```console
8383
Length in inches: 30

0 commit comments

Comments
 (0)