Design Patterns: Extend Functionality without Modifying Existing Code using OCP

Level : Beginner
Mentor: Shailendra Chauhan
Type : GuidedLab
Points : 10
Duration : 00:15:00

Lab Details

Problem Statement:

A lab to follow the OCP principle while doing your code in C#.

  • Create a C# class named Invoice that calculates invoice amounts.
  • Extend the Invoice class to support different invoices (e.g., DomesticInvoice, InternationalInvoice) .
  • Implement the new invoice types without modifying the original Invoice class code.
  • Use the Program class to demonstrate the usage of DomesticInvoice and InternationalInvoice classes for calculating invoice amounts.

Lab Objective:

Upon completion of this lab, you will be able to:

  • Understand the Open-Closed Principle (OCP) of software design.
  • Capability to add features without changing the current code directly.
  • Proficiency in developing and deploying inheritance-based C# solutions for handling various invoice types.

Prerequisites

You should install the following software on your machine:

  • VS Code or Visual Studio
  • .NET SDK
Self-paced Membership
  • 22+ Video Courses
  • 800+ Hands-On Labs
  • 400+ Quick Notes
  • 55+ Skill Tests
  • 45+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this