lab report
lab report
On
Design Pattern
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
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:
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:
Source: geeksforgeeks
Key Features:
• Defines a set of interchangeable algorithms.
• Promotes loose coupling between algorithm and client.
• Enhances maintainability and scalability.
Code:
Output: