Skip to content

Commit 21be468

Browse files
authored
Merge pull request #49456 from wwlpublish/f03d74d794def66d41cdc5e2822a9bd18a606243c37e8566345a59a751be2ccf-live
Modules/M02-implement-polymorphic-behavior
2 parents db96fee + fe77231 commit 21be468

14 files changed

+57
-28
lines changed

learn-pr/wwl-azure/implement-polymorphic-behavior/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"
7-
ms.date: 03/06/2025
7+
ms.date: 03/10/2025
88
author: wwlpublish
99
ms.author: cahowd
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 3
1214
content: |
1315
[!include[](includes/1-introduction.md)]

learn-pr/wwl-azure/implement-polymorphic-behavior/2-examine-principles-polymorphism.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Examine the principles of polymorphic behavior
44
metadata:
55
title: Examine the principles of polymorphic behavior
66
description: "Examine the principles of polymorphic behavior"
7-
ms.date: 03/06/2025
7+
ms.date: 03/10/2025
88
author: wwlpublish
99
ms.author: cahowd
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 5
1214
content: |
1315
[!include[](includes/2-examine-principles-polymorphism.md)]

learn-pr/wwl-azure/implement-polymorphic-behavior/3-explore-inheritance-based-polymorphism.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Explore inheritance-based polymorphism
44
metadata:
55
title: Explore inheritance-based polymorphism
66
description: "Explore inheritance-based polymorphism"
7-
ms.date: 03/06/2025
7+
ms.date: 03/10/2025
88
author: wwlpublish
99
ms.author: cahowd
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 10
1214
content: |
1315
[!include[](includes/3-explore-inheritance-based-polymorphism.md)]

learn-pr/wwl-azure/implement-polymorphic-behavior/4-explore-interface-based-polymorphism.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Explore interface-based polymorphism
44
metadata:
55
title: Explore interface-based polymorphism
66
description: "Explore interface-based polymorphism"
7-
ms.date: 03/06/2025
7+
ms.date: 03/10/2025
88
author: wwlpublish
99
ms.author: cahowd
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 10
1214
content: |
1315
[!include[](includes/4-explore-interface-based-polymorphism.md)]

learn-pr/wwl-azure/implement-polymorphic-behavior/5-review-polymorphic-design-considerations.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Review polymorphic design considerations
44
metadata:
55
title: Review polymorphic design considerations
66
description: "Review polymorphic design considerations"
7-
ms.date: 03/06/2025
7+
ms.date: 03/10/2025
88
author: wwlpublish
99
ms.author: cahowd
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 8
1214
content: |
1315
[!include[](includes/5-review-polymorphic-design-considerations.md)]

learn-pr/wwl-azure/implement-polymorphic-behavior/6-exercise-implement-polymorphism-csharp-app.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Exercise - Implement polymorphism in a C# app
44
metadata:
55
title: Exercise - Implement polymorphism in a C# app
66
description: "Exercise - Implement polymorphism in a C# app"
7-
ms.date: 03/06/2025
7+
ms.date: 03/10/2025
88
author: wwlpublish
99
ms.author: cahowd
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 30
1214
content: |
1315
[!include[](includes/6-exercise-implement-polymorphism-csharp-app.md)]

learn-pr/wwl-azure/implement-polymorphic-behavior/7-knowledge-check.yml

Lines changed: 3 additions & 1 deletion
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: 03/06/2025
7+
ms.date: 03/10/2025
88
author: wwlpublish
99
ms.author: cahowd
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 4
1214
quiz:
1315
title: "Check your knowledge"

learn-pr/wwl-azure/implement-polymorphic-behavior/8-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: 03/06/2025
7+
ms.date: 03/10/2025
88
author: wwlpublish
99
ms.author: cahowd
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 3
1214
content: |
1315
[!include[](includes/8-summary.md)]

learn-pr/wwl-azure/implement-polymorphic-behavior/includes/1-introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Polymorphism is one of the core concepts of object-oriented programming (OOP). Polymorphism enables objects of different classes to be treated as objects of a common base class, providing flexibility and reusability in code.
1+
Polymorphism is one of the core concepts of object-oriented programming. Polymorphism enables objects of different types to be treated as objects of a common base type, providing flexibility and reusability in code.
22

33
Suppose you're working at a non-profit company that's in the midst of a software update project. The application combines tightly coupled models with a loosely coupled reporting structure. You're tasked with implementing polymorphism in the application to enhance flexibility and maintainability. You need to understand how to implement polymorphic behavior using class inheritance and interfaces. This module guides you through these concepts and provides practical examples to help you apply them in your work.
44

learn-pr/wwl-azure/implement-polymorphic-behavior/includes/2-examine-principles-polymorphism.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
Polymorphism allows objects of different classes to be treated as objects of a common base class. This behavior enables you to write code that works with objects of multiple types without knowing the specific type at compile time.
1+
Polymorphism allows objects of different types to be treated as objects of a common base type. This behavior enables you to write code that works with objects of multiple types without knowing the specific type at compile time.
22

33
For example, consider a base class `Shape` with derived classes `Circle` and `Rectangle`. You can create a list of `Shape` objects and add instances of `Circle` and `Rectangle` to it. When you iterate over the list, you can call the `Draw` method on each object without knowing the specific type of the object. This process is an example of polymorphic behavior in action.
44

55
## Approaches to polymorphism in C#
66

77
C# developers can implement polymorphism using either of the following approaches:
88

9-
- Inheritance-based polymorphism: Class inheritance in C# enables a derived class to inherit members from a base class. Members of the base class can be overridden in the derived class to provide specific implementations. Creating a class hierarchy is a common way to implement polymorphism in C#.
9+
- Inheritance-based polymorphism: Class inheritance in C# enables a derived class to inherit members from a base class. Members of the base class can be overridden in the derived class to provide specific implementations. When you create instances of the base class that reference the derived class types, you can access members of the derived class from the base class objects. Inheritance-based polymorphism is a common way to implement polymorphism in C#.
1010

11-
- Interface-based polymorphism: An interface in C# defines a contract that classes can implement. When a class implements an interface, the class receives a set of properties and methods that it's required to implement. This requirement allows for polymorphic behavior, where an interface reference can direct objects of different classes to implement the set of properties and methods.
11+
- Interface-based polymorphism: An interface in C# defines a contract that classes can implement. When a class implements an interface, the class receives a set of properties and methods that it's required to implement. This requirement allows for polymorphic behavior, where an interface reference can direct objects of different classes to implement the set of properties and methods. Interface-based polymorphism is another common way to implement polymorphism in C#.
1212

1313
## Method overloading versus method overriding
1414

@@ -24,16 +24,16 @@ This training focuses on method overriding, which is a key aspect of polymorphis
2424

2525
Polymorphism is based on the following principles:
2626

27-
- Method Overriding: Method overriding allows a derived class to provide a specific implementation of a method that's already defined in its base class. This capability is made possible by inheritance and is a key aspect of runtime polymorphism.
28-
- Virtual and Abstract Methods: The virtual keyword is used to declare methods in the base class that can be overridden in derived classes. The abstract keyword is used for declaring methods that must be overridden in derived classes.
29-
- Base Class References: Polymorphism allows a base class reference to point to objects of derived classes. This inheritance mechanism enables the invocation of overridden methods in derived classes through the base class reference.
30-
- Interface-Based Polymorphism: Interfaces define a contract that classes can implement. This contract allows different classes to be treated uniformly through a common interface, promoting loose coupling and flexibility.
27+
- Method overriding: Method overriding allows a derived class to provide a specific implementation of a method that's already defined in its base class. This capability is made possible by inheritance and is a key aspect of runtime polymorphism.
28+
- Virtual and abstract methods: The virtual keyword is used to declare methods in the base class that can be overridden in derived classes. The abstract keyword is used for declaring methods that must be overridden in derived classes.
29+
- Base class references: Polymorphism allows a base class reference to point to objects of derived classes. This inheritance mechanism enables the invocation of overridden methods in derived classes through the base class reference.
30+
- Interface-based polymorphism: Interfaces define a contract that classes can implement. This contract allows different classes to be treated uniformly through a common interface, promoting loose coupling and flexibility.
3131

3232
## Benefits of polymorphism
3333

34-
- Code Reusability: Polymorphism promotes code reusability by allowing the same code to work with different types of objects.
34+
- Code reusability: Polymorphism promotes code reusability by allowing the same code to work with different types of objects.
3535

36-
- Flexibility and Maintainability: Polymorphism enhances flexibility and maintainability by decoupling the code that uses objects from the code that defines the objects.
36+
- Flexibility and maintainability: Polymorphism enhances flexibility and maintainability by decoupling the code that uses objects from the code that defines the objects.
3737

3838
- Extensibility: Polymorphism makes it easier to extend the system by adding new classes that implement the same interface or inherit from the same base class.
3939

0 commit comments

Comments
 (0)