0% found this document useful (0 votes)
0 views

lab report

The lab report discusses three design patterns: Singleton, Decorator, and Strategy. It outlines their theories, key features, and provides code examples for each pattern. The report is submitted by Shajib Chanda for the Software Engineering & Design Pattern Lab course at Metropolitan University, Bangladesh.

Uploaded by

sajibchanda73
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

lab report

The lab report discusses three design patterns: Singleton, Decorator, and Strategy. It outlines their theories, key features, and provides code examples for each pattern. The report is submitted by Shajib Chanda for the Software Engineering & Design Pattern Lab course at Metropolitan University, Bangladesh.

Uploaded by

sajibchanda73
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Lab Report

On

Design Pattern

(Singleton, Decorator and Strategy)

Course Code: CSE - 418

Course Title: Software Engineering & Design Pattern Lab

Submitted to:

Plabon Talukder
Lecturer
Department of Computer Science & Engineering
Metropolitan University, Bangladesh

Submitted by:
Shajib Chanda
ID: 222-115-172
Batch: 57th (E)
Department of Computer Science & Engineering
Metropolitan University, Bangladesh

Date of Submission: 01February 2025


1. Singleton Design Pattern-
Theory:
The Singleton Pattern ensures that a class has only one instance and provides a global point
of access to it. This is useful in scenarios where multiple instances could cause
inconsistencies, such as logging, configuration management, or database connections.

Source: geeksforgeeks
Key Features:
• Ensures only one instance of a class is created.
• Provides global access to that instance.
• Uses a private constructor to restrict instantiation.
Code:
Output Example:

Output:

2. Decorator Design Pattern-


Theory:
The Decorator Pattern dynamically adds responsibilities to objects without modifying their
structure. Instead of subclassing, it wraps an object with new functionality, making it more
flexible and reusable.

Source: geeksforgeeks
Key Features:
• Allows behavior to be added dynamically at runtime.
• Follows the Open-Closed Principle (open for extension, closed for modification).
• Uses composition rather than inheritance.
Code:

Output:

3. Strategy Design Pattern-


Theory:
The Strategy Pattern allows defining a family of algorithms, encapsulating them in separate
classes, and making them interchangeable at runtime. This promotes flexibility by enabling
dynamic selection of the desired algorithm.

Source: geeksforgeeks
Key Features:
• Defines a set of interchangeable algorithms.
• Promotes loose coupling between algorithm and client.
• Enhances maintainability and scalability.

Code:

Output:

You might also like