ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Object Oriented Analysis and Design
    COMP3150
    Progress0 / 17 topics
    Topics
    1. Principles of Object Technology2. OOP Review3. Principles of Modeling4. OOA&D Overview5. OO Development Process6. Requirements Engineering: Use Cases and Prototyping7. Class Models8. Interaction Diagrams9. Verification and Validation10. Architectural and Detailed Design11. Class Diagrams12. State Machines and Diagrams13. Implementation and Package Diagrams14. Activity Diagrams15. OO Patterns16. Object Diagram, Component Diagram, and Deployment Diagram17. Network Diagram
    COMP3150›OO Patterns
    Object Oriented Analysis and DesignTopic 15 of 17

    OO Patterns

    3 minread
    524words
    Beginnerlevel

    📘 OO Patterns (Object-Oriented Design Patterns)


    🔹 1. Definition

    Object-Oriented (OO) Patterns are reusable solutions to common software design problems that occur in object-oriented systems.

    👉 Simple idea: Instead of solving the same design problem again and again, we use a proven template (pattern).


    🔹 2. Why OO Patterns are Important ⭐

    • Reusable solutions (save time)
    • Improve code quality
    • Reduce design errors
    • Make system easier to maintain
    • Encourage best practices

    🔹 3. Key Idea

    A design pattern is NOT code. It is a:

    "Blueprint for solving a recurring design problem"


    🔹 4. Types of OO Design Patterns

    Design patterns are mainly divided into 3 categories:


    🔷 4.1 Creational Patterns (Object Creation)

    👉 These patterns deal with how objects are created


    🔸 1. Singleton Pattern ⭐

    Definition: Ensures only one instance of a class exists.

    Example:

    • Database connection
    • Printer spooler
    class Database {
      private static Database instance;
    }
    

    👉 Only one object is shared globally.


    🔸 2. Factory Pattern

    Definition: Creates objects without exposing creation logic.

    Example: Car factory → produces different cars


    🔸 3. Builder Pattern

    Definition: Builds complex objects step by step.

    Example: Burger customization (bun, cheese, sauce)


    🔷 4.2 Structural Patterns (Class/Object Structure)

    👉 These patterns deal with how classes and objects are structured


    🔸 1. Adapter Pattern ⭐

    Definition: Converts one interface into another compatible interface.

    Example: Mobile charger adapter


    🔸 2. Decorator Pattern

    Definition: Adds new behavior to an object without changing its structure.

    Example: Adding toppings to pizza 🍕


    🔸 3. Facade Pattern

    Definition: Provides a simple interface to a complex system.

    Example: ATM hides banking system complexity


    🔷 4.3 Behavioral Patterns (Object Communication)

    👉 These patterns deal with how objects interact and communicate


    🔸 1. Observer Pattern ⭐

    Definition: One-to-many relationship where one object notifies others.

    Example: YouTube channel subscription 🔔


    🔸 2. Strategy Pattern

    Definition: Defines multiple algorithms and selects one at runtime.

    Example: Payment methods (Card, UPI, Cash)


    🔸 3. Command Pattern

    Definition: Encapsulates a request as an object.

    Example: Remote control buttons 📺


    🔹 5. Real-Life Example of Patterns ⭐

    🎯 ATM System

    • Singleton → ATM machine instance
    • Strategy → Withdrawal methods (cash/card)
    • Facade → ATM hides banking system complexity

    🔹 6. Benefits of OO Patterns

    • Reusability
    • Flexibility
    • Better communication among developers
    • Faster development
    • Standardized solutions

    🔹 7. Problems Without Patterns

    • Duplicate code
    • Poor structure
    • Difficult maintenance
    • Hard to scale system

    🔹 8. Important Rules / Guidelines

    • Use patterns only when needed
    • Do NOT overuse patterns
    • Choose correct pattern for correct problem
    • Keep design simple

    🔹 9. Pattern vs Algorithm

    Feature Design Pattern Algorithm
    Purpose Design solution Step-by-step logic
    Level High-level design Low-level implementation
    Focus Structure & interaction Computation

    🔹 10. Likely Exam Questions

    1. Define OO design patterns.
    2. Why are design patterns important?
    3. Explain Singleton pattern.
    4. What is Factory pattern?
    5. Explain Adapter pattern with example.
    6. What is Observer pattern?
    7. Difference between design pattern and algorithm.
    8. Types of design patterns.
    9. Explain Strategy pattern.
    10. Real-life applications of OO patterns.

    🔹 11. Quick Revision Summary 🧠

    🔹 OO Patterns = Reusable design solutions

    🔹 Types:

    • Creational → Object creation
    • Structural → Object structure
    • Behavioral → Object interaction

    👉 Trick to Remember: "CSB" → Creational, Structural, Behavioral


    Previous topic 14
    Activity Diagrams
    Next topic 16
    Object Diagram, Component Diagram, and Deployment Diagram

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time3 min
      Word count524
      Code examples0
      DifficultyBeginner