Composition Vs Inheritance
Composition Vs Inheritance
classBook{
Stringtitle;
Stringauthor;
StringgetTitle() {
returntitle;
}
voidsetTitle(Stringtitle) {
[Link]= title;
}
StringgetAuthor() {
returnauthor;
}
voidsetAuthor(Stringauthor) {
[Link]= author;
}
}
classInventoryView{
Bookbook;
InventoryView(Bookbook) {
[Link]= book;
}
voidsearchBook() {...}
}
how the hell it can use Book book inside inveenteory woithout inheritemnce interfaec what is it
doing what happening with thw code
Great question — you're on the right track trying to understand how `InventoryView` is using `Book`
without inheritance or interfaces.
Let's break this down clearly and simply — without any fluff.
class InventoryView {
Book book; // ✅This is a reference to a Book object.
}
[Link] = book; // ✅ Book is passed into the constructor and stored in the 'book' variabl
InventoryView(Book book) {
void searchBook() {
// This method can use '[Link]()', '[Link]()', etc.
}
}
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/77
❓ So, how is this possible without inheritance or interface?
Because:
🔸 This is not inheritance.
🔸 This is composition.
📘 What is Composition?
Composition is when one class contains an object of another class — like how `InventoryView` has a
`Book`.
📌 Summary
Concept Meaning In Your Code
Inheritance "Is-a" relationship ❌ Not used here
Interface Contract for polymorphism ❌ Not used here
Composition "Has-a" relationship ✅ `InventoryView` has a `Book`
🧠 Memory Trick:
🧩 If a class uses another class as a field → It's composition, not inheritance.
🗣️ "InventoryView has a Book" → Composition.
Would you like a visual diagram or mind map of this to make it stick better?
SIR
Try AI directly in your favourite apps … Use Gemini to generate drafts and refine content, plus get
Gemini Advanced with access to Google's next-gen AI for ₹1,950.00 ₹0 for 1 month
class Student
{
String name;
String id;
Student(String id, String name)
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 2/77
{
[Link] = id;
[Link] = name;
}
void display()
{
[Link]([Link]+ " "+[Link]);
}
}
class Student_good
{
Student s;
Student_good(Student s)
{
this.s = s;
}
String search_name(String st)
{
if([Link] != st)
return "not available";
else
return [Link];
}
}
class Student_test
{
public static void main(String[] args)
{
Student s1 = new Student("wf1513","sindhu");
//[Link]();
Student s2 = new Student("1513","indhu");
Student s3 = new Student("wf","shyama");
Student_good SG1= new Student_good(s1);
[Link](SG1.search_name("151"));
[Link](SG1.search_name("wf1513"));
}
}
class Student
{
String name;
String id;
Student(String id, String name)
{
[Link] = id;
[Link] = name;
}
void display()
{
[Link]([Link]+ " "+[Link]);
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/77
}
String search_name(String id)
{
if(id != "1513")
return "not available";
else
return name;
}
}
How what id this code doing it work of flow with how SIR
You're doing a great job digging into these concepts — let's simplify this for you clearly.
class Student {
String name;
String id;
void display() {
[Link]([Link] + " " + [Link]);
}
}
class Student_good {
Student s;
Student_good(Student s) {
this.s = s;
}
java
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 4/77
[Link](SG1.search_name("151"));
[Link](SG1.search_name("wf1513"));
// Output: not available
// Output: not available ❌ (Why? Keep reading)
if ([Link] != st)
This compares strings using `!=`, which compares memory addresses, not actual string content.
if ()
java
java
class Student {
String name;
String id;
void display() {
[Link]([Link] + " " + [Link]);
}
You don’t need a second class like `Student_good`. You just let each `Student` search themselves.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 5/77
🧠 Memory Trick to Remember:
🧩
`!=` compares object location in memory, not value
`.equals()` compares actual string content
💡 Summary
Design Description Problem
Composition One class holds a `Student` and Used `!=` for string
(`Student_good`) searches comparison
Would you like me to create a side-by-side diagram comparing both versions of this design?
}
void display()
{
[Link]([Link]+ " "+[Link]);
}
double calculate_bonus(double salary)
{
if(type== "Permanent")
return salary*0.1;
else
return salary*0.05;
}
}
*/
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 6/77
String id;
String name;
Employee(){}
Employee(String id, String name)
{
[Link] = id;
[Link] = name;
}
void display()
{
[Link]([Link]+ " "+[Link]);
}
abstract double calculate_bonus(double salary);
}
Temporary(){}
Temporary(String id, String name)
{
super(id,name);
}
double calculate_bonus(double salary)
{
return salary*0.05;
}
Contract(){}
Contract(String id, String name)
{
super(id,name);
}
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 7/77
double calculate_bonus(double salary)
{
try{
class Employee_test
{
public static void main(String[] args)
{
/*Employee e1 = new Employee("wf1513","sindhu","Permanent");
Employee e2 = new Employee("1513","indhu","Temporary");
[Link](e1.calculate_bonus(10000));
[Link](e2.calculate_bonus(20000));
*/
}
}
Explain in depth this code what it does and how and where and when . Then tell me workflow what
runs then what whthen what run ... . Also Finally how OCP principle is used in this code , without
OCp what would have happend
Fantastic question! You’re diving deep into real object-oriented design now, especially with abstract
classes and the Open/Closed Principle (OCP). Let’s break this down piece by piece.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 8/77
Temporary employee gets 5% bonus.
🔧 Structure Overview
1. Abstract Class: `Employee`
java
Each extends `Employee` and provides its own logic for `calculate_bonus`.
✅ `Permanent`:
java
✅ `Temporary`:
java
✅ `Contract`:
java
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 9/77
return 0.0;
}
java
Uses polymorphism to calculate the bonus based on the actual employee type.
`e1` → `Permanent`
`e2` → `Temporary`
`e3` → `Contract`
✅ Software entities (classes, modules, functions) should be open for extension, but
closed for modification.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 10/77
java
class Employee {
String type;
...
double calculate_bonus(double salary) {
if ([Link]("Permanent"))
return salary * 0.1;
else if ([Link]("Temporary"))
return salary * 0.05;
else
return 0.0;
}
}
❌ Problems:
Every time a new employee type is added (e.g., Intern), you have to modify this method.
Violates OCP → Frequent modification leads to bugs, tight coupling, and fragile code.
✅ Extendability You can add new employee types without touching old code
🔚 Final Summary
🎯 What It Does:
Calculates bonus based on employee type using polymorphism.
⚙️ Execution Order:
1. `main()` → creates objects
🛡️ OCP Usage:
Abstract class `Employee` is closed for modification
New logic is added via subclasses, keeping base class untouched
Clean, extensible, and future-proof
Would you like a mind map of this design or a class diagram to help visualize it better?
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 11/77
Scenario-based exercise to apply each SOLID principle
Online Food ordering
• A food delivery platform allows users to order food
online from multiple restaurants. It includes the following
key features:
❑ User Management(Register/Login, Address Management)
❑ Restaurant Management (Menu, Pricing, Availability)
❑ Order Processing(Order Placement, Payment, Delivery Tracking)
• Now, let's apply each SOLID principle to design the
system.
Object Oriented Analysis and Design
Single Responsibility Principle (SRP)
Problem:
A single Order class is responsible for multiple tasks:
• Managing order details (items, price, restaurant)
• Processing payments
• Sending order confirmation notifications
Object Oriented Analysis and Design
Single Responsibility Principle (SRP)
Solution:
class Order {
private List<Item> items;
private double total Price;
public void addItem(Item item) {
/* Add item logic */
}
public double calculateTotal() {
/* Calculate total price */
}
}
class PaymentProcessor {
public void processPayment(Order order, PaymentMethod method) {
/* Payment logic */
}
}
class NotificationService {
public void sendOrderConfirmation(User user, Order order) {
/* Send email/SMS */ }
}
Object Oriented Analysis and Design
Open-Closed Principle (OCP)
Problem:
The PaymentProcessor class has a processPayment() method that only supports
Credit Card payments. If we need to add PayPal, UPI, or Wallets, we have to
modify the existing class, violating OCP.
Solution:
Use Polymorphism—create an interface for payments, and extend it for new
payment methods without modifying existing code.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 12/77
Object Oriented Analysis and Design
Open-Closed Principle (OCP)
interface PaymentMethod {
void pay(double amount);
}
class CreditCardPayment implements PaymentMethod {
public void pay(double amount) { /* Credit Card logic */ }
}
class PayPalPayment implements PaymentMethod {
public void pay(double amount) { /* PayPal logic */ }
}
class PaymentProcessor {
public void processPayment(PaymentMethod method, double
amount) {
[Link](amount);
}
}
Object Oriented Analysis and Design
Liskov Substitution Principle (LSP)
Problem:
We have a DeliveryPerson class that has a deliverOrder() method. Now, we
introduce DroneDelivery for automated delivery.
If DroneDelivery extends DeliveryPerson, it inherits methods like
assignVehicle() that drones don't need, leading to incorrect behavior.
Solution:
Use a common interface instead of forcing inheritance.
Object Oriented Analysis and Design
Liskov Substitution Principle (LSP)
interface DeliveryService {
void deliverOrder(Order order);
}
class DeliveryPerson implements DeliveryService {
public void deliverOrder(Order order) { /* Assign person and
vehicle */ }
}
class DroneDelivery implements DeliveryService {
public void deliverOrder(Order order) { /* Autonomous drone
delivery */ }
}
Object Oriented Analysis and Design
Interface Segregation Principle (ISP)
Problem:
•
ARestaurantService interface has methods:
addMenuItem()
•
•
updateStock()
generateMonthlyReport()
A small home-based restaurant only wants to manage menu items but is
forced to implement generateMonthlyReport(), which it doesn’t need.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 13/77
Solution:
• Split into smaller interfaces.
Object Oriented Analysis and Design
Interface Segregation Principle (ISP)
interface MenuManagement {
void addMenuItem(Item item);
void updateStock(Item item, int quantity);
}
interface Reporting {
void generateMonthlyReport();
}
class SmallRestaurant implements MenuManagement {
public void addMenuItem(Item item) { /* Add item logic */ }
public void updateStock(Item item, int quantity) { /* Stock logic
*/ }
}
Object Oriented Analysis and Design
Dependency Inversion Principle (DIP)
Problem:
• OrderService directly depends on MySQLDatabase to store orders. If we
switch to MongoDB, we need to change multiple parts of the system.
Solution:
• Depend on abstractions instead of concrete classes.
Object Oriented Analysis and Design
Dependency Inversion Principle (DIP)
interface Database {
void saveOrder(Order order);
}
class MySQLDatabase implements Database {
public void saveOrder(Order order) { /* MySQL logic */ }
}
class MongoDBDatabase implements Database {
public void saveOrder(Order order) { /* MongoDB logic */ }
}
}
Object Oriented Analysis and Design
Dependency Inversion Principle (DIP)
class OrderService {
private Database database;
public OrderService(Database database) {
[Link] = database;
}
public void placeOrder(Order order) {
[Link](order);
}
PROBLEM , AND HOW DID HE SOLVE IT WIIITH SHOW OLD COODE THAT I HAVE PASTE AND THEN
ITS PROBELM AND SOLUTION CODE AND MODIFIED WITH HOW MOFDIFIED
Absolutely! Let's walk through your scenario step by step. For each SOLID principle, I’ll:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 14/77
1. Show the problem code (before applying the principle)
2. Explain the issue
3. Show the refactored code (after applying the principle)
class Order {
private List<Item> items;
private double totalPrice;
🚨 Problem:
`Order` class has too many responsibilities:
Order logic
Payment logic
Notification logic
This makes it hard to test, reuse, or change individual parts
class Order {
private List<Item> items;
private double totalPrice;
class PaymentProcessor {
public void processPayment(Order order, PaymentMethod method) {
/* Payment logic */
}
}
class NotificationService {
public void sendOrderConfirmation(User user, Order order) {
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 15/77
/* Send email/SMS */
}
}
class PaymentProcessor {
public void processPayment(double amount, String method) {
if ([Link]("CreditCard")) {
// Credit Card logic
} else if ([Link]("PayPal")) {
// PayPal logic
} else if ([Link]("UPI")) {
// UPI logic
}
}
}
🚨 Problem:
Every time a new method (like Wallet) is added, you must modify this class
interface PaymentMethod {
void pay(double amount);
}
class PaymentProcessor {
public void processPayment(PaymentMethod method, double amount) {
[Link](amount);
}
}
class DeliveryPerson {
void deliverOrder(Order order) { /* Assign person */ }
🚨 Problem:
`DroneDelivery` is forced to inherit `assignVehicle()`, which is not relevant
Violates LSP: Subclasses should be usable as their parent class without breaking logic
interface DeliveryService {
void deliverOrder(Order order);
}
interface RestaurantService {
void addMenuItem(Item item);
void updateStock(Item item, int qty);
void generateMonthlyReport(); // Not needed for small restaurants
}
🚨 Problem:
Small restaurants are forced to implement unnecessary methods
Violates ISP: Classes should only depend on what they actually use
interface MenuManagement {
void addMenuItem(Item item);
void updateStock(Item item, int quantity);
}
interface Reporting {
void generateMonthlyReport();
}
class OrderService {
private MySQLDatabase database;
public OrderService() {
[Link] = new MySQLDatabase();
}
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 18/77
public void placeOrder(Order order) {
[Link](order);
}
}
🚨 Problem:
`OrderService` is tightly coupled to `MySQLDatabase`
You can’t switch to MongoDB or other databases easily
interface Database {
void saveOrder(Order order);
}
class OrderService {
private Database database;
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 19/77
Principle Before Problem After Benefit
Easy to switch or
DIP Class depends on MySQL Hard to switch DB Use abstraction
test
Would you like a visual mind map or class diagram summarizing all these principles applied to the online
food delivery system?
Uploaded image
DIFFERENTIATE BETWEEN DESIGN PATEERN VS ARCHITECTURAL PATTERNS 5-6 POINTS WITH 2
MEMORY TRICKS SIMPLE POINTS WITH EXAMPLSES . REFER THE IMAGE AND INCLUDE THOSE TOO
Here's a simple and structured comparison between Design Patterns and Architectural Patterns,
based on your image and extra examples, followed by 2 memory tricks to help you remember.
Defines system components and their Defines reusable solutions to sub-problems within
Scope
interactions components
- Client-Server - Singleton
- Layered Architecture - Observer
Examples
- Microservices - Factory
- MVC - Strategy
Provides a blueprint for overall application
Purpose Provides flexible collaboration between objects
structure
🧠 Memory Tricks
🎯 Trick 1: “A” is for “Application”, “D” is for “Detail”
Architecture → Whole Application structure (macro-level)
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 20/77
🔁 With Examples
Architecture:
You use Layered Architecture to divide your food delivery app into UI, Business Logic, and
Database layers.
Design Pattern:
You use Observer Pattern to notify the user and delivery person when the order status
changes.
Would you like a small diagram or mind map showing this visually for quick revision?
Code (Java)
Printer
public class Printer {
private static Printer printer;
private int nrOfPages;
private Printer() {
}
public static Printer getInstance() {
return printer == null ?
printer = new Printer() :
printer;
}
public void print(String text){
[Link](text +
"n" + "Pages printed today " + ++nrOfPages +
"n" + "---------");
}
}
Employee
public class Employee {
private final String name;
private final String role;
private final String assignment;
public Employee(String name, String role, String assignment)
{
[Link] = name;
[Link] = role;
[Link] = assignment;
}
public void printCurrentAssignment(){
Printer printer = [Link]();
[Link]("Employee: " + name + "n" +
"Role: " + role + "n" +
"Assignment: " + assignment + "n");
}
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 21/77
}
Object Oriented Analysis and Design with Java
Code (Java)
How To Use The Singleton Pattern
public class Main {
public static void main(String[] args) {
Employee graham = new Employee("Graham", "CEO", "Making excutive decisions");
Employee sara = new Employee("Sara","Consultant", "Consuting the company");
Employee tim = new Employee("Tim","Salesmen", "Selling the company's products");
Employee emma = new Employee("Emma", "Developer", "Developing the latest mobile app.");
[Link]();
[Link]();
[Link]();
[Link]();
}
}
Object Oriented Analysis and Design with Java
Applicability
Use the Singleton pattern when
❑there must be exactly one instance of a class, and it must be accessible to
clients from a well-known access point.
❑when the sole instance should be extensible by subclassing, and clients
should be able to use an extended instance without modifying their code.
Object Oriented Analysis and Design with Java
Structure
Object Oriented Analysis and Design with Java
Participants
❑Singleton design pattern has two core participants: Singleton and Client.
❑defines an Instance operation that lets clients access its unique
instance. Instance is a class operation (that is, a class method and a static
member function).
❑may be responsible for creating its own unique instance.
Object Oriented Analysis and Design with Java
Collaborations
Clients access a Singleton instance solely through Singleton's
Instance operation.
Object Oriented Analysis and Design with Java
Consequence
The Singleton pattern has several benefits:
1. Controlled access to sole instance. Because the Singleton class encapsulates its sole
instance, it can have strict control over how and when clients access it.
1. Reduced name space. The Singleton pattern is an improvement over global variables. It
avoids polluting the name space with global variables that store sole instances.
1. Permits refinement of operations and representation. The Singleton class may be
subclassed, and it's easy to configure an application with an instance of this extended
class. You can configure the application with an instance of the class you need at run
time.
Object Oriented Analysis and Design with Java
Consequence
The Singleton pattern has several benefits:
4. Permits a variable number of instances. The pattern makes it easy to change your mind
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 22/77
and allow more than one instance of the Singleton class. Moreover, you can use the same
approach to control the number of instances that the application uses. Only the operation
that grants access to the Singleton instance needs to change
5. More flexible than class operations. Another way to package a singleton's functionality is
to use class operations (that is, static member functions or class methods). But both of these
language techniques make it hard to change a design to allow more than one instance of a
class. Moreover, static member functions in class are compile time, so subclasses can't
override them polymorphically.
EXPLAIN FOR ME . ALSO MAKE ME UNDERSTNAD HOW TO EXPLAIN THIS , EXPLAIN TEH CODE TO
ME' HOW IT WORKS , RUN , WORK FLOW AND WHY IT IS SINGELOTPON . aND FINALLY COMMON
TEMPLATE THAT SINGELTON ALWAYS FOLLOW MEMOERY TRICKS TO FOLLOW IN EXAMP TO GET
MARKS
Great! Let's break everything down step by step to fully understand the Singleton Design Pattern,
especially with respect to:
class SingletonClass {
private static SingletonClass instance;
private SingletonClass() {
// private constructor
}
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 23/77
Public static `getInstance()` method (global access point)
java
java
java
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 24/77
Employee graham = new Employee("Graham", "CEO", "Making decisions");
Employee sara = new Employee("Sara", "Consultant", "Consulting");
Employee tim = new Employee("Tim", "Salesman", "Selling products");
Employee emma = new Employee("Emma", "Developer", "Developing app");
[Link]();
[Link]();
[Link]();
[Link]();
}
}
Private constructor
Public static `getInstance()`
📌 Code Points:
Constructor is private ✅
Static instance created lazily ✅
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 25/77
Access only via `getInstance()` ✅
📌 Benefits:
Saves memory
Global object access
Prevents duplication
Would you like a short mind map or diagram to revise this quickly?
Implementation
Java Singleton Pattern Implementation
[Link] a private static field to the class for storing the singleton instance.
[Link] a public static creation method for getting the singleton instance.
[Link] “lazy initialization” inside the static method. It should create a new object on its
first call and put it into the static field. The method should always return that instance on all
subsequent calls.
[Link] the constructor of the class private. The static method of the class will still be able to
call the constructor, but not the other objects.
[Link] over the client code and replace all direct calls to the singleton’s constructor with calls
to its static creation method.
Object Oriented Analysis and Design with Java
Implementation
variousdesign options for implementing Singleton:
Method 1: lazy instantiation
// Classical Java implementation of singleton design pattern
class Singleton
{
private static Singleton obj;
// private constructor to force use of
// getInstance() to create Singleton object
private Singleton() {}
}
❑Here we have declared getInstance()
static so that we can call it without
instantiating the class.
public static Singleton getInstance()
{
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 26/77
if (obj==null)
obj = new Singleton();
return obj;
}
❑The first time getInstance() is called
it creates a new singleton object and
after that it just returns the same
object.
❑Note that Singleton obj is not created
until we need it and call getInstance()
method. This is called lazy
instantiation.
Object Oriented Analysis and Design with Java
Implementation
The main problem with above method is that it is not thread safe.
Consider the following execution sequence.
This execution sequence creates two objects for singleton.
Therefore this classic implementation is not thread safe.
Object Oriented Analysis and Design with Java
Implementation
Method 2: make getInstance() synchronized
// Thread Synchronized Java implementation of
// singleton design pattern
class Singleton
{
private static Singleton obj;
private Singleton() {}
}
❑Here using synchronized makes sure
that only one thread at a time can
execute getInstance().
// Only one thread can execute this at a time
public static synchronized Singleton getInstance()
{
if (obj==null)
obj = new Singleton();
return obj;
}
❑The main disadvantage of this is
method is that using synchronized
every time while creating the singleton
object is expensive and may decrease
the performance of your program.
❑However if performance of
getInstance() is not critical for your
application this method provides a
clean and simple solution.
Object Oriented Analysis and Design with Java
Implementation
Method 3: Eager Instantiation
// Static initializer based Java implementation of
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 27/77
// singleton design pattern
class Singleton
{
private static Singleton obj = new
Singleton();
private Singleton() {}
❑Here we have created instance of
singleton in static initializer.
❑JVM executes static initializer when the
class is loaded and hence this is
guaranteed to be thread safe.
public static Singleton getInstance()
{
return obj;
}
}
❑ Use this method only when your
singleton class is light and is used
throughout the execution of your
program.
Object Oriented Analysis and Design with Java
Pros and Cons
PROS
1. You can be sure
that a class has only
a single instance.
CONS
1. Violates the Single Responsibility Principle. The pattern solves
two problems at the time.
2. The Singleton pattern can mask bad design, for instance, when the
2. You gain a global
access point to that
instance.
3.
The singleton
object is initialized
only
when it’s
requested for the
first time.
components of the program know too much about each other.
3. The pattern requires special treatment in a multithreaded
environment so that multiple threads won’t create a singleton
object several times.
4. It may be difficult to unit test the client code of the Singleton
because many test frameworks rely on inheritance when producing
mock objects.
EXPLAIN THIS FOR NEWBIE IN DEPTH
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 28/77
Absolutely! Let’s now go step-by-step and explain everything clearly for a beginner so that you
understand what Singleton is, how it is implemented in Java, why we need it, the different ways to do it,
and the pros and cons. I’ll also give memory tricks, exam tips, and diagrams (if you'd like one).
So:
class Singleton {
private static Singleton obj;
❌ Problem:
Not thread safe. If two threads call `getInstance()` at the same time, two objects may be created.
class Singleton {
private static Singleton obj;
private Singleton() {}
✅ Safe
But ⛔ slow – every time method is called, Java locks it → reduces performance.
✅ Method 3: Eager Instantiation (Fast but Always Created)
java
class Singleton {
private static Singleton obj = new Singleton(); // created immediately
private Singleton() {}
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 30/77
public static Singleton getInstance() {
return obj;
}
}
Lazy Instantiation ❌ ✅ ✅ ✅
Synchronized ✅ ❌ ✅ ✅
Eager Instantiation ✅ ✅ ❌ ✅
🔷 Pros and Cons of Singleton
✅ Pros
1. ✅ One instance only – saves memory and prevents conflicts
2. ✅ Global access – easy to get the object anywhere
3. ✅ Lazy loading (in lazy method) – created only when needed
❌ Cons
1. ❌ Breaks Single Responsibility Principle – class handles both its main job + instance control
2. ❌ Hidden dependencies – other parts of the program may rely too much on it
3. ❌ Thread-safety issues – in lazy method without sync
4. ❌ Difficult to unit test – because you can’t easily mock or override the Singleton instance
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 31/77
Key Concept Quick Trick
Thread Safe Method Synchronized, slow but safe
Singleton ensures that only one object of a class is created and provides a global point of
access to it.
Structure
Implementation Types
Applicability
Pros
Memory-efficient
Global access
Lazy initialization
Cons
Would you like a mind map or diagram of these 3 types for revision?
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 32/77
public Animal getAnimal(String animal) {
if([Link](null)) return null;
if([Link]("Dog")) {
return new Dog();
} else if([Link]("Cat")) {
return new Cat();
} else if([Link]("Rabbit")) {
return new Rabbit();
}
return null;
}
}
Try AI directly in your favourite apps … Use Gemini to generate drafts and refine content, plus get
Gemini Advanced with access to Google's next-gen AI for ₹1,950.00 ₹0 for 1 month
public class Cat implements Animal {
@Override
public void eat() {
[Link]("Cat is eating, meow!");
}
}
Try AI directly in your favourite apps … Use Gemini to generate drafts and refine content, plus get
Gemini Advanced with access to Google's next-gen AI for ₹1,950.00 ₹0 for 1 month
public class Client {
public static void main(String[] args) {
AnimalFactory animalFactory = new AnimalFactory();
Explain this code in depth . EXPLAIN FOR ME . ALSO MAKE ME UNDERSTNAD HOW TO EXPLAIN THIS
, EXPLAIN TEH CODE TO ME' HOW IT WORKS , RUN , WORK FLOW AND WHY IT IS SINGELOTPON .
aND FINALLY COMMON TEMPLATE THAT abstract factory or factory ALWAYS FOLLOW MEMOERY
TRICKS TO FOLLOW IN EXAMP TO GET MARKS
Great! Let's break this down step-by-step for you like a beginner. This code is a classic example of the
Factory Design Pattern, not Singleton. So don’t worry — I’ll explain Factory Pattern in-depth and show
how this code works, how to explain it in exams, what memory tricks to remember, and how to spot it
easily.
java
🧠 Think of `Animal` as a common blueprint. Every animal must implement the `eat()` method. It
helps us treat all animals uniformly.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 34/77
2. Concrete Implementations
java
✅ Each class implements `Animal` and gives its own version of `eat()`.
java
if([Link]("Dog")) {
return new Dog();
} else if([Link]("Cat")) {
return new Cat();
} else if([Link]("Rabbit")) {
return new Rabbit();
}
return null;
}
}
🔍 Key points:
Method `getAnimal(String animal)` returns an `Animal` object.
Based on input (`"dog"`, `"cat"`...), it creates and returns the correct subclass (`Dog`, `Cat`, or
`Rabbit`).
You don’t use `new` in `main()` – you just ask the factory.
java
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 35/77
Animal animal = [Link]("dog");
[Link](); // prints "Dog is eating, woof!"
🔄 Workflow:
1. `main()` creates one AnimalFactory object
2. Calls `getAnimal()` with a string
3. Factory decides what class to create
// Product interface
public interface Product {
void someMethod();
}
// Factory class
public class ProductFactory {
public Product getProduct(String type) {
if ([Link]("A")) return new A();
else if ([Link]("B")) return new B();
return null;
}
}
// Client
ProductFactory factory = new ProductFactory();
Product p = [Link]("A");
[Link]();
Factory (`AnimalFactory`)
Client (`main()`)
4. Benefits?
Loose coupling
Central object creation logic
Easy to maintain/scale
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 37/77
Feature Singleton Pattern Factory Pattern
Object Count Exactly one Multiple as needed
Main method `getInstance()` `getObject()`, `getAnimal()` etc.
Example Printer, Logger AnimalFactory, ShapeFactory
Would you like a mind map image or a handwritten-style notes image for revision?
Uploaded image
Applicability
Use the Factory pattern when
❑a class can't anticipate the class of objects it must create.
❑a class wants its subclasses to specify the objects it creates.
❑classes delegate responsibility to one of several helper subclasses, and you want to localize the
knowledge of which helper subclass is the delegate.
Object Oriented Analysis and Design
Structure
Object Oriented Analysis and Design
Participants
❑Product -defines the interface of objects the factory method creates.
❑ConcreteProduct - implements the Product interface.
❑Creator - declares the factory method, which returns an object of type [Link] may
also define a default implementation of the factory method that returns a default
ConcreteProduct object. - may call the factory method to create a Product object.
❑ConcreteCreator -overrides the factory method to return an instance of a ConcreteProduct.
Object Oriented Analysis and Design
Collaboration
Creator relies on its subclasses to define the factory method so that it
returns an instance of the appropriate ConcreteProduct.
Object Oriented Analysis and Design
Consequence
1. Provides hooks for subclasses. Creating objects inside a class with a factory method is
always more flexible than creating an object directly. Factory Method gives subclasses a
hook for providing an extended version of an object.
2. Connects parallel class hierarchies. In the examples we've considered so far, the factory method
is
only called by Creators. But this doesn't have to be the case; clients can find factory methods useful,
especially in the case of parallel class hierarchies.
Parallel class hierarchies result when a class delegates some of its responsibilities to a separate
class.
Consider graphical figures that can be manipulated interactively; that is, they can be stretched,
moved, or rotated using the mouse. Implementing such interactions isn't always easy. It often
requires storing and updating information that records the state of the manipulation at a given
time.
Object Oriented Analysis and Design
Pros and Cons
Object Oriented Analysis and Design
Relationship with other pattern
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 38/77
Object Oriented Analysis and Design
Issues to consider when using the Factory pattern
[Link] major varieties. The two main variations of the Factory Method pattern are (1) the case when
the
Creator class is an abstract class and does not provide an implementation for the factory method it
declares, and (2) the case when the Creator is a concrete class and provides a default
implementation for
the factory method. It's also possible to have an abstract class that defines a default
implementation, but
this is less common. The first case requires subclasses to define an implementation, because
there's no
reasonable default.
[Link] factory methods. Another variation on the pattern lets the factory method create
multiple kinds of products. The factory method takes a parameter that identifies the kind of object
to
create. All objects the factory method creates will share the Product interface.
[Link]-specific variants and issues. Different languages lend themselves to other interesting
variations and caveats. Smalltalk programs often use a method that returns the class of the object
to be
instantiated. A Creator factory method can use this value to create a product, and a
ConcreteCreator may
store or even compute this value. The result is an even later binding for the type of
ConcreteProduct to be
instantiated.
Object Oriented Analysis and Design
Pros and Cons
You avoid tight coupling between the creator and the concrete products.
Single Responsibility Principle. You can move the product creation code into one place in the
program, making the code easier to support.
Open/Closed Principle. You can introduce new types of products into the program without breaking
existing client code.
× The code may become more complicated since you need to introduce a lot of new subclasses to
implement the pattern. The best case scenario is when you're introducing the pattern into an
existing hierarchy of creator classes
Relations with Other Patterns Many designs start by using Factory Method (less complicated and
more customizable via subclasses) and evolve toward Abstract Factory, Prototype, or Builder (more
flexible, but more complicated). Abstract Factory classes are often based on a set of Factory
Methods, but you can also use Prototype to compose the methods on these classes. You can use
Factory Method along with Iterator to let collection subclasses return different types of iterators
that are compatible with the collections. Prototype isn't based on inheritance, so it doesn't have its
drawbacks. On the other hand, Prototype requires a complicated initialization of the cloned object.
Factory Method is based on inheritance but doesn't require an initialization step. Factory Method is
a specialization of Template Method. At the same time, a Factory Method may serve as a step in a
large Template Method.
explain the above in depth above words , an=bbove sentence and above image inn simplified
unnderstanble way and organize it understandable form with mindmap in depth in detailed usefull
summary mindmap
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 39/77
Uploaded image
Applicability
Use the Factory pattern when
❑a class can't anticipate the class of objects it must create.
❑a class wants its subclasses to specify the objects it creates.
❑classes delegate responsibility to one of several helper subclasses, and you want to localize the
knowledge of which helper subclass is the delegate.
Object Oriented Analysis and Design
Structure
Object Oriented Analysis and Design
Participants
❑Product -defines the interface of objects the factory method creates.
❑ConcreteProduct - implements the Product interface.
❑Creator - declares the factory method, which returns an object of type [Link] may
also define a default implementation of the factory method that returns a default
ConcreteProduct object. - may call the factory method to create a Product object.
❑ConcreteCreator -overrides the factory method to return an instance of a ConcreteProduct.
Object Oriented Analysis and Design
Collaboration
Creator relies on its subclasses to define the factory method so that it
returns an instance of the appropriate ConcreteProduct.
Object Oriented Analysis and Design
Consequence
1. Provides hooks for subclasses. Creating objects inside a class with a factory method is
always more flexible than creating an object directly. Factory Method gives subclasses a
hook for providing an extended version of an object.
2. Connects parallel class hierarchies. In the examples we've considered so far, the factory method
is
only called by Creators. But this doesn't have to be the case; clients can find factory methods useful,
especially in the case of parallel class hierarchies.
Parallel class hierarchies result when a class delegates some of its responsibilities to a separate
class.
Consider graphical figures that can be manipulated interactively; that is, they can be stretched,
moved, or rotated using the mouse. Implementing such interactions isn't always easy. It often
requires storing and updating information that records the state of the manipulation at a given
time.
Object Oriented Analysis and Design
Pros and Cons
Object Oriented Analysis and Design
Relationship with other pattern
Object Oriented Analysis and Design
Issues to consider when using the Factory pattern
[Link] major varieties. The two main variations of the Factory Method pattern are (1) the case when
the
Creator class is an abstract class and does not provide an implementation for the factory method it
declares, and (2) the case when the Creator is a concrete class and provides a default
implementation for
the factory method. It's also possible to have an abstract class that defines a default
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 40/77
implementation, but
this is less common. The first case requires subclasses to define an implementation, because
there's no
reasonable default.
[Link] factory methods. Another variation on the pattern lets the factory method create
multiple kinds of products. The factory method takes a parameter that identifies the kind of object
to
create. All objects the factory method creates will share the Product interface.
[Link]-specific variants and issues. Different languages lend themselves to other interesting
variations and caveats. Smalltalk programs often use a method that returns the class of the object
to be
instantiated. A Creator factory method can use this value to create a product, and a
ConcreteCreator may
store or even compute this value. The result is an even later binding for the type of
ConcreteProduct to be
instantiated.
Object Oriented Analysis and Design
Pros and Cons
You avoid tight coupling between the creator and the concrete products.
Single Responsibility Principle. You can move the product creation code into one place in the
program, making the code easier to support.
Open/Closed Principle. You can introduce new types of products into the program without breaking
existing client code.
× The code may become more complicated since you need to introduce a lot of new subclasses to
implement the pattern. The best case scenario is when you're introducing the pattern into an
existing hierarchy of creator classes
Relations with Other Patterns Many designs start by using Factory Method (less complicated and
more customizable via subclasses) and evolve toward Abstract Factory, Prototype, or Builder (more
flexible, but more complicated). Abstract Factory classes are often based on a set of Factory
Methods, but you can also use Prototype to compose the methods on these classes. You can use
Factory Method along with Iterator to let collection subclasses return different types of iterators
that are compatible with the collections. Prototype isn't based on inheritance, so it doesn't have its
drawbacks. On the other hand, Prototype requires a complicated initialization of the cloned object.
Factory Method is based on inheritance but doesn't require an initialization step. Factory Method is
a specialization of Template Method. At the same time, a Factory Method may serve as a step in a
large Template Method.
explain the above in depth above words , an=bbove sentence and above image inn simplified
unnderstanble way and organize it understandable form with mindmap in depth in detailed usefull
summary mind flow map with text only with mind tricks rememveru g
Here's a simplified and well-structured mind map with text-only flow, breaking down the Factory
Method Pattern with detailed explanation, memory tricks, and flow organization for easy
understanding and last-minute revision.
🔑 Memory Trick:
“Factory → Family → Figure Out”
→ The factory gives birth to a family of objects, but lets each child figure out its own type!
🧱 2. STRUCTURE (Participants)
Main Characters (like a play!):
vbnet
🧩
🧩 Product → Interface for the objects created.
📌 Mnemonic: C → c → P
(Creator → concreteCreator → Product)
⚖️ 5. CONSEQUENCES
🟢 Pros:
✅ Hooks for subclasses: Easily extensible.
✅ Parallel Class Hierarchies: Product & Creator grow together.
✅ Loose Coupling: Creator doesn’t need to know product class.
✅ Open/Closed Principle: Add new products without touching core logic.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 42/77
✅ Single Responsibility Principle: Creation code is in one place.
🔴 Cons:
❌ More subclasses.
❌ Code may look complex if overused.
🧠 Trick:
Use the “POP-C” acronym:
Parallel Hierarchy, Open/Closed, Plug-in product types, Complicated when overused.
🧪 6. VARIANTS
1. Abstract Creator (no default factory method – subclasses must implement it).
🧠 Trick to remember:
Abstract → All subclasses must define.
Concrete → Can give a default.
🧠 Trick:
"FAB-IT" =
Factory Method → leads to Abstract Factory/Builder
Iterator + Factory
Template Method parent
plaintext
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 43/77
4. ApplicationOne returns new ProductOne (concrete).
5. Creator uses factoryMethod() → returns the product created by subclass.
Would you like a printable PDF version of this mind map with a visual diagram too?
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 44/77
aware of the complex process and logic required to build that specific instance.
❑This helps us create Single Responsibility classes for
complex object creation while at the same time ensuring
separation of object creation from business logic.
❑Based
on
the
nature
of
the
application, Builder implementations might lead to code
re-usability,
reducing
the
code
base
and
improving SOLID compliance of our code.
Object Oriented Analysis and Design
Builder
Definition:
The Builder Design Pattern is another creational pattern designed to deal with the
construction of comparatively complex objects.
When the complexity of creating object increases, the Builder pattern can separate
out the instantiation process by using another object (a builder) to construct the
object.
This builder can then be used to create many other similar representations using a simple
step-by-step approach.
Object Oriented Analysis and Design
Why Builder Pattern?
The Builder design pattern solves problems like:
❑How can a class (the same construction process) create different representations of a complex
object?
❑How can a class that includes creating a complex object be simplified?
The Builder design pattern describes how to solve such problems:
❑Encapsulate creating and assembling the parts of a complex object in a separate Builder object.
❑A class delegates object creation to a Builder object instead of creating the objects directly.
A class (the same construction process) can delegate to different Builder objects to create different
representations of a complex object.
Object Oriented Analysis and Design
Builder : Class, Object Structural
Motivation
❑A reader for the RTF (Rich Text Format) document exchange format should be able
to convert RTF to many text formats. The reader might convert RTF documents into
plain ASCII text or into a text widget that can be edited interactively.
❑The problem, however, is that the number of possible conversions is open-ended. So
it should be easy to add a new conversion without modifying the reader.
❑A solution is to configure the RTFReader
class with a TextConverter object that converts RTF
to another textual representation.
❑The Builder pattern captures all these
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 45/77
relationships. Each converter class is
called a builder in the pattern, and the
reader is called the director.
Object Oriented Analysis and Design
Builder : Class, Object Structural
Intent
Separate the construction of a complex object from its
representation so that the same construction process can
create different representations
Think of a car factory
Boss tells workers (or robots) to build each part of a car
Workers build each part and add them to the car being
constructed
Object Oriented Analysis and Design
Builder : Implementation
UML class diagram for the Builder Pattern
Builder
Abstract interface for creating objects (product).
ConcreteBuilder
Provides implementation for Builder. It is an object able to construct
other objects. Constructs and assembles parts to build the objects.
Class Diagram
Object Oriented Analysis and Design
Builder : Implementation example-1
Problem Statement: Case study
❑We will set the objective of making a burger
restaurant, which can make different variations
of burgers.
❑Secondly it would also be preferable to
have defined instructions for how to build each of
the different variations of burgers (e.g.
cheeseburger), so that we do not have to provide all
the ingredients each time when we are making a
burger.
❑Before, how the builder design pattern will be able
to solve these issues, we will start by seeing how
this system could be build based on construction of
the burger object in the main context.
Object Oriented Analysis and Design
Builder : Implementation example-1
Solution: Construction In The Main Context
public class Main {
public static void main(String[] args) {
Burger cheeseBurger = new Burger();
[Link]("White Bread");
[Link]("Beef");
[Link]("Iceberg");
}
[Link]("American Chesse");
[Link]("Secret Sauce");
[Link]();
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 46/77
Object Oriented Analysis and Design
Solution: Concept Of The Builder Pattern
❑When talking about the builder
design pattern, it is important to
understand
the
concept
the Director and the Builder.
of
❑The director’s job is to invoke the
building process of the builder. The
builder’s job is to manage the
different
building
procedures
associated with each of the different
variations of objects, in this case the
burgers.
❑The builder pattern consists of two
classes, a sub- and super class.
Object Oriented Analysis and Design
Design Solution :Class Diagram (UML)
❑Builder pattern consists of two main class types: the
builder and the director
❑With the context of program we will be using the builder
pattern, it means we actually only want to be interacting
with the director.
❑The director will ensure that we build the correct burger
object based on which builder we provide it with.
❑Inside the director, we set its builder object field
(setBuilder-method) and afterwards ask it to build the
object based on the provided builder (build-method).
Object Oriented Analysis and Design
Solution : Java Code
Link to java implementation
Note: Java files in the src/builderPatternDemo (it’s a eclipse source file)
Object Oriented Analysis and Design
Applicability
Use the Builder pattern when
❑The algorithm for creating a complex object should be independent of the parts that make up the
object and how they're assembled.
❑Theconstruction process must allow different representations for the object that's constructed.
❑You want to get rid of a “telescoping constructor”. Say you have a constructor with ten optional
parameters. Calling such a beast is very inconvenient; therefore, you overload the constructor and
create several shorter versions with fewer parameters.
❑You want your code to be able to create different representations of some product (for example,
stone and wooden houses). The Builder pattern can be applied when construction of various
representations of the product involves similar steps that differ only in the details.
Object Oriented Analysis and Design
Structure
Object Oriented Analysis and Design
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 47/77
Participants
Builder (TextConverter)
o specifies an abstract interface for creating parts of a Product object.
ConcreteBuilder (ASCIIConverter, TeXConverter, TextWidgetConverter)
o constructs and assembles parts of the product by implementing the Builder interface.
o defines and keeps track of the representation it creates.
o provides an interface for retrieving the product (e.g., GetASCIIText, GetTextWidget). ·
Director (RTFReader)
o constructs an object using the Builder interface.
Product (ASCIIText, TeXText, TextWidget)
o represents the complex object under construction. ConcreteBuilder builds the product's
internal representation and defines the process by which it's assembled.
o includes classes that define the constituent parts, including interfaces for assembling the
parts into the final result.
Object Oriented Analysis and Design
Collaboration
❑Client creates Director object and
configures it with a Builder
❑Director notifies Builder to build each
part of the product
❑Builder handles requests from Director
and adds parts to the product
❑Client retrieves product from the Builder
The following interaction diagram illustrates how Builder and Director
cooperate with a client.
Object Oriented Analysis and Design
Consequence
❑Lets you vary a product’s internal representation by using
different Builders
❑Isolates code for construction and representation
❑Gives finer-grain control over the construction process
Object Oriented Analysis and Design
Issues to consider when using the Builder pattern
❑Assembly and construction interface: generality
❑Is an abstract class for all Products necessary?
❑Usually products don’t have a common interface
❑Usually there’s an abstract Builder class that defines an operation for each component that
a director may ask it to create.
❑These operations do nothing by default (empty, static methods )
❑The ConcreteBuilder overrides operations selectively
Object Oriented Analysis and Design
How to Implement
[Link] sure that you can clearly define the common construction steps for building all available
product representations.
[Link] these steps in the base builder interface.
[Link] a concrete builder class for each of the product representations and implement their
construction steps.
[Link] about creating a director class. It may encapsulate various ways to construct a product
using the same builder object.
[Link] client code creates both the builder and the director objects. Before construction starts, the
client must pass a builder object to the director.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 48/77
[Link] construction result can be obtained directly from the director only if all products follow the
same interface. Otherwise, the client should fetch the result from the builder.
Object Oriented Analysis and Design
Pro and Cons
Pros
❑You can construct objects step-by
step, defer construction steps or run
steps recursively.
❑ You can reuse the same construction
code
when
building
representations of products.
various
❑ Single Responsibility Principle. You
can isolate complex construction code
from the business logic of the product.
Cons
❑The overall complexity of the
code increases since the
pattern
requires
multiple new classes.
creating
Object Oriented Analysis and Design
Relations with Other Patterns
❑ Manydesigns start by using Factory Method (less complicated and more customizable via
subclasses) and
evolve toward Abstract Factory, Prototype, or Builder (more flexible, but more complicated).
❑ Builder focuses on constructing complex objects step by step. Abstract Factory specializes in
creating
families of related objects. Abstract Factory returns the product immediately, whereas Builder lets
you run
some additional construction steps before fetching the product.
❑ You can use Builder when creating complex Composite trees because you can program its
construction
steps to work recursively.
❑ You can combine Builder with Bridge: the director class plays the role of the abstraction, while
different
builders act as implementations.
❑ Abstract Factories, Builders and Prototypes can all be implemented as Singletons
explain the abive in above words , above sentences with more organisze and understnaadable way
with final summary mindmap in text at final
Here's a well-organized explanation of the content you shared, focusing on two major OOAD design
patterns — Factory Method and Builder Pattern — with all key points simplified, categorized, and
concluded with a text-based mind map summary.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 49/77
🏭 Factory Method Pattern – Explained
🔍 Introduction:
The Factory Method Pattern is a creational design pattern used to define an interface for creating
objects, but allows subclasses to alter the type of objects that will be created.
✅ Issues to Consider:
1. Two Major Varieties
The factory method can accept parameters to produce different types of objects.
Useful when objects share a common interface but differ in behavior or configuration.
3. Language-Specific Variants
In Smalltalk, factory methods may return classes to be instantiated later (very dynamic).
🛠️ Definition:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 50/77
Delegates construction to a Builder class.
Maintains Single Responsibility Principle (SRP).
Separates object creation logic from business logic.
⚙️ Applicability:
Use Builder Pattern when:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 51/77
Need to replace complex constructors with a clean step-by-step process.
👥 Collaboration Flow:
1. Client creates `Director` and sets a `Builder`.
2. Director calls build steps.
3. Builder assembles the object.
4. Client retrieves final product from the builder.
📌 Issues to Consider:
Builders may not share a common `Product` interface.
Use an abstract builder with empty method definitions.
❌ Cons:
Increases class count and code complexity.
Builder Pattern
├── Purpose
│ └── Separate complex object creation from its use
├── Key Components
│ ├── Builder (interface)
│ ├── ConcreteBuilder (steps for each product)
│ ├── Director (controls steps)
│ └── Product (final object)
├── Examples
│ ├── RTF Reader
│ └── Burger Builder
├── Benefits
│ ├── Flexibility in object construction
│ └── Avoids telescoping constructors
└── Drawbacks
└── More classes and setup required
Would you like a diagram version of the Builder Pattern class structure or mind map as an image for
revision?
Try AI directly in your favourite apps … Use Gemini to generate drafts and refine content, plus get
Gemini Advanced with access to Google's next-gen AI for ₹1,950.00 ₹0 for 1 month
package builderPatternDemo;
}
Try AI directly in your favourite apps … Use Gemini to generate drafts and refine content, plus get
Gemini Advanced with access to Google's next-gen AI for ₹1,950.00 ₹0 for 1 month
package builderPatternDemo;
//Builder
public abstract class BurgerBuilder {
Burger build(){
return burger;
};
}
Try AI directly in your favourite apps … Use Gemini to generate drafts and refine content, plus get
Gemini Advanced with access to Google's next-gen AI for ₹1,950.00 ₹0 for 1 month
package builderPatternDemo;
//Director
public class BurgerResuturant {
}
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 54/77
Try AI directly in your favourite apps … Use Gemini to generate drafts and refine content, plus get
Gemini Advanced with access to Google's next-gen AI for ₹1,950.00 ₹0 for 1 month
package builderPatternDemo;
explain this code for newbie . Explain this code in depth . EXPLAIN FOR ME . ALSO MAKE ME
UNDERSTNAD HOW TO EXPLAIN THIS , EXPLAIN TEH CODE TO ME' HOW IT WORKS , RUN , WORK
FLOW AND WHY IT IS SINGELOTPON . aND FINALLY COMMON or fixed TEMPLATE THAT abstract
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 55/77
factory or factory ALWAYS FOLLOW MEMOERY TRICKS TO FOLLOW IN EXAMP TO GET MARKS
Update memory?
YesNo
Great! Let’s break this Builder Pattern Java code down piece-by-piece in a very beginner-friendly way,
explaining what it does, how it runs, how to explain it in exams, and memory tricks. We’ll end with a
common template and memory aid to answer Builder, Factory, or Abstract Factory questions.
🍔 Real-life Analogy:
Think of a burger restaurant. The chef (builder) knows how to make burgers step by step. The
manager (director) just says, “Make me a cheese burger!” and the chef does the steps: bun → meat →
salad → cheese → sauce.
java
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 56/77
We give it a `CheeseBurgerBuilder`, a specific recipe for a cheeseburger.
java
This:
Calls the builder steps inside the Director: bun, meat, salad, cheese, sauce.
Each step is defined in `CheeseBurgerBuilder`.
java
[Link]("White Bread");
[Link]("Beef");
...
markdown
Burger is finished!
- Bun: White Bread
- Meat: Beef
- Cheese: American Cheese
- Salad: Iceberg
- Sauce: Secret Sauce
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 57/77
🧠 Memory Trick: PBCD-C
scss
P – Product (Burger)
B – Builder (Abstract class with build steps)
C – ConcreteBuilder (CheeseBurgerBuilder)
D – Director (BurgerResuturant)
C – Client (Main class)
Product One interface, many One product, many Many products from same
Variations subclasses configurations family
Object
Simple Complex Grouped
Construction
ShapeFactory → BurgerBuilder → GUIFactory → MacButton,
Example
Circle/Square Cheese/VeganBurger MacScrollBar
BUILDER PATTERN
├── Purpose: Construct complex object step-by-step
├── Key Roles
│ ├── Product (Burger)
│ ├── Builder (BurgerBuilder)
│ ├── ConcreteBuilder (CheeseBurgerBuilder)
│ ├── Director (BurgerResuturant)
│ └── Client (Main)
├── Pros
│ ├── Clear separation of construction and representation
│ ├── Flexible object creation
│ └── Avoids telescoping constructors
├── Cons
│ └── Many extra classes
├── When to Use?
│ ├── Object has many parts/configs
│ ├── Construction must be stepwise
├── Example
│ └── Burger restaurant: Chef builds step-by-step
Agenda
Prototype-definition
Motivation
Intent
Implementation
Applicability
Structure-Consequence
Issues
Motivation
The Prototype Pattern specify the kind of objects to create using a prototypical instance, and create
new
objects by copying this prototype.
Use the Prototype Pattern when a client needs to create a set of objects that are alike or differ from
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 59/77
each
other only in terms of their state and creating an instance of a such object (e.g., using the “new”
keyword) is either expensive or complicated.
The Prototype Pattern allows you to make new instances by copying existing instances.
– In Java this typically means using the clone() method or de-serialization when you need deep
copies
– Client code can make new instances without knowing which specific class is being
instantiated
Intent
Prototype is a creational design pattern that lets you copy existing objects without making
your code dependent on their classes.
Prototype : Implementation
Problem Statement:
In this example, the Prototype pattern lets you produce exact copies of geometric objects, without
coupling the code to their classes.
Let’s take a look at how the Prototype can be implemented without the standard Cloneable
interface.
Prototype registry
You could implement a centralized prototype registry (or factory), which would contain a set of pre-
defined
prototype objects. This way you could retrieve new objects from the factory by passing its name or
other
parameters. The factory would search for an appropriate prototype, clone it and return you a copy.
Applicability
Use the Prototype pattern when a system should be independent of how its products are created,
composed, and represented; and
when the classes to instantiate are specified at run-time, for example, by dynamic loading; or
to avoid building a class hierarchy of factories that parallels the class hierarchy of products; or
when instances of a class can have one of only a few different combinations of state. It may be
more convenient to install a corresponding number of prototypes and clone them rather than
instantiating the class manually, each time with the appropriate state.
Structure
Collaboration
Consequence
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 61/77
Specifying new objects by varying values
Reduced subclassing.
Using a prototype manager. : When the number of prototypes in a system isn't fixed (that is, they
can be created and destroyed dynamically), keep a registry of available prototypes. Clients won't
manage prototypes themselves but will store and retrieve them from the registry. A client will ask
the registry for a prototype before cloning it. We call this registry a prototype manager.
Implementing the Clone operation. The hardest part of the Prototype pattern is implementing
the Clone operation correctly. It's particularly tricky when object structures contain circular
references.
Initializing clones. While some clients are perfectly happy with the clone as is, others will want
to initialize some or all of its internal state to values of their choosing. You generally can't pass
these values in the Clone operation, because their number will vary between classes of prototypes.
Some prototypes might need multiple initialization parameters; others won't need any. Passing
parameters in the Clone operation precludes a uniform cloning interface.
Sure! Let’s explain the Prototype Design Pattern for a newbie using your provided notes, structured
simply, step-by-step. This will include the agenda, definitions, intent, examples, structure, and
memory tricks, using only the content and terms you’ve already provided.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 62/77
📌 Prototype - Definition (What is it?)
Prototype pattern specifies the kind of objects to create using a prototypical instance and
lets you create new objects by copying this prototype.
👉 This means:
Instead of using `new` to create objects,
You copy (clone) an existing object,
Which is helpful when object creation is expensive or complex.
🧠 Key Idea: Make new instances by copying existing instances, not by creating from scratch.
🎯 Intent
“Prototype is a creational design pattern that lets you copy existing objects without making
your code dependent on their classes.”
🧠 In Java:
Use `clone()` method
Use `Cloneable` interface
Or use serialization for deep copy
🏗️ Implementation
Classes implement a common interface with a `clone()` or `copy()` method.
Subclasses override clone to copy their own field values.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 63/77
Registry clones and returns the copy
✅ Example:
java
👥 Collaboration:
Client doesn’t create objects directly
It asks a prototype from the registry and clones it
✅ Consequence (Advantages)
Add/remove product types at runtime
Create new objects by changing values or structure
Reduce subclassing
Dynamically configure application
⚠️ Issues
When using Prototype, consider:
1. Prototype Manager
Use a central registry to store and manage prototypes
2. Implementing Clone
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 64/77
3. Initializing Clones
Some objects may need custom initialization after cloning
1. Intent:
- Copy existing objects
- Without depending on class
2. Motivation:
- Use when object creation is expensive
- Only state differs
3. Structure:
- Client → Prototype → clone()
4. Implementation:
- Use clone() / Cloneable / serialization
5. Applicability:
- Runtime creation
- Avoid factory hierarchies
- Few state combinations
6. Consequences:
- Add/remove at runtime
- Reduce subclassing
7. Issues:
- Prototype Manager
- Clone correctness
- Clone initialization
🎓 Memory Tip:
"Prototype = Copy-paste objects!"
"Don't `new` it, clone it!"
Would you like the full Java code + UML of Prototype like in the previous Builder example?
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 65/77
the Adaptee).
❑ The main advantage is that the object
Adapter adapts not only the Adaptee but
all its subclasses. All it's subclasses with
one "small" restriction: all the subclasses
which don't add new methods, because
the used mechanism is delegation. So for
any new method the Adapter must be
changed or extended to expose the new
methodsas well.
❑ Themain disadvantage is that it requires
to write all the code for delegating all
the necessary requests to the Adaptee.
❑ Class adapter uses inheritance instead of
composition. It means that instead of
delegating the calls to the Adaptee, it
subclasses it. In conclusion it must subclass
both the Target and the Adaptee.
❑ There are advantages and disadvantages:
It adapts the specific Adaptee class. The
class it extends. If that one is subclassed it
can not be adapted by the existing adapter.
❑ It doesn't require all the code required for
delegation, which must be written for an
Object Adapter.
❑ If the Target is represented by an interface
instead of a class then we can talk about
"class" adapters, because we can implement
as many interfaces as we want
simplify but don't miss any word . Give 8 points , Simple and examples
Here’s a simplified explanation of Class Adapter vs Object Adapter (used in the Adapter Design
Pattern) in 8 clear points, with examples, and no missing information from your notes:
✅ 1. Structure Difference
Object Adapter → Uses composition
👉 It has an instance of Adaptee (uses it internally).
Class Adapter → Uses inheritance
👉 It extends the Adaptee (inherits from it).
✅ 2. Delegation vs Inheritance
Object Adapter: Uses delegation
👉 Calls are forwarded to Adaptee’s methods.
Class Adapter: Uses inheritance
👉 Calls are directly done because it's a subclass.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 66/77
✅ 3. Subclass Support
Object Adapter: Can adapt Adaptee and all its subclasses
✅ But only if subclasses don’t add new methods.
Class Adapter: Only adapts one Adaptee class, not its subclasses.
✅ 4. Code Writing
Object Adapter: ❌ You must write all delegation code manually.
Class Adapter: ✅ No need to write delegation code, it’s automatic via inheritance.
✅ 5. Flexibility
Object Adapter: ✅
More flexible
👉 You can change the Adaptee at runtime.
Class Adapter: ❌ Less flexible
👉 It's statically bound (fixed at compile time).
✅ 6. Interface Support
Class Adapter: ✅ If Target is an interface, you can implement many interfaces.
Object Adapter: Usually handles only one Adaptee instance.
class AudioPlayer {
MediaAdapter adapter;
void play(String audioType, String fileName) {
if([Link]("vlc")) {
adapter = new MediaAdapter("vlc");
[Link](audioType, fileName);
}
}
}
// AudioPlayer delegates to MediaAdapter → Object Adapter
class Socket {
int getVolts() { return 120; }
}
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 67/77
}
// SocketAdapter inherits from Socket → Class Adapter
💡 Summary Table
Feature Object Adapter Class Adapter
Structure Composition (has-a) Inheritance (is-a)
Code Delegation Manual Not needed
Supports Subclasses ✅ (limited) ❌
Flexibility High Low
Interface Use ❌ Limited ✅ Can implement many
Example Use Media Adapter Socket Adapter
Would you like a diagram (UML or comparison chart) for this too?
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 68/77
• Management is unwilling to make firm decisions about when parts of the domain are
sufficiently described.
• The project vision and focus on the goal/deliverable to customer is diffused. Analysis
goes beyond providing meaningful value.
Object Oriented Analysis and Design
Project Management AntiPatterns – Analysis Paralysis
Refactored Solution:
• Key to the success of object-oriented development is incremental development. Whereas
a waterfall process assumes a priori knowledge of the problem, incremental development
processes assume that details of the problem and its solution will be learned in the course
of the development process.
• There are two kinds of increments: internal and external. An internal increment builds
software that is essential to the infrastructure of the implementation. For example, a third
tier database and data-access layer would comprise an internal increment. Internal
increments build a common infrastructure that is utilized by multiple use cases. In
general, internal increments minimize rework. An external increment comprises user
visible functionality.
Object Oriented Analysis and Design
Software Architecture Antipatterns
• Architecture AntiPatterns focus on the system-level and enterprise-level
structure of applications and components.
• Although the engineering discipline of software architecture is relatively
immature, what has been determined repeatedly by software research and
experience is the overarching importance of architecture in software
development.
The following AntiPatterns focus on some common problems and mistakes in
the creation, implementation, and management of architecture.
Object Oriented Analysis and Design
Software Architecture Antipatterns – Vendor Lock-In
Vendor Lock-In
• Asoftware project adopts a product technology and becomes completely dependent
upon the vendor's implementation. When upgrades are done, software changes and
interoperability problems occur, and continuous maintenance is required to keep the
system running.
• Inaddition, expected new product features are often delayed, causing schedule slips
and an inability to complete desired application software features.
Object Oriented Analysis and Design
Software Architecture Antipatterns – Vendor Lock-In
Vendor Lock-In – Symptoms and Consequences
• Commercial product upgrades drive the application software maintenance cycle.
• Promised product features are delayed or never delivered, subsequently, causing failure to
deliver application updates.
• Theproduct varies significantly from the advertised open systems standard.
• If a product upgrade is missed entirely, a product repurchase and reintegration is often
necessary.
Object Oriented Analysis and Design
Software Architecture Antipatterns – Vendor Lock-In
Vendor Lock-In – Typical Causes
• The product varies from published open system standards because there is no effective
conformance process for the standard.
• Theproduct is selected based entirely upon marketing and sales information, and not upon
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 69/77
more detailed technical inspection.
• There is no technical approach for isolating application software from direct dependency upon the
product.
• Application programming requires in-depth product knowledge.
• The complexity and generality of the product technology greatly exceeds that of the application
needs; direct dependence upon the product results in failure to manage the complexity of the
application system architecture.
Object Oriented Analysis and Design
Software Architecture Antipatterns – Vendor Lock-In
Vendor Lock-In – Refactored Solution
The refactored solution to the Vendor Lock-In AntiPattern is called isolation layer. An isolation
layer separates software packages and technology. This solution is applicable when one or more
of the following conditions apply:
• Isolation of application software from lower-level infrastructure. This infrastructure may
include middleware, operating systems, security mechanisms, or other low-level mechanisms.
• Changes to the underlying infrastructure are anticipated within the life cycle of the affected
software; for example, new product releases or planned migration to new infrastructure.
• A more convenient programming interface is useful or necessary. The level of abstraction
provided by the infrastructure is either too primitive or too flexible for the intended
applications and systems.
• There is a need for consistent handling of the infrastructure across many systems. Some
heavyweight conventions for default handling of infrastructure interfaces must be instituted.
• Multiple infrastructures must be supported, either during the life cycle or concurrently.
Object Oriented Analysis and Design
Software Development Antipatterns
Good software structure is essential for system extension and maintenance. Software
development is a chaotic activity, therefore the implemented structure of systems tends to
stray from the planned structure as determined by architecture, analysis, and design.
Object Oriented Analysis and Design
Software Development Antipatterns – The Blob
The Blob
Procedural-style design leads to one object with a lion’s share of the responsibilities, while most
other
objects only hold data or execute simple processes. The solution includes refactoring the design to
distribute responsibilities more uniformly and isolating the effect of changes.
Background:
The Blob is found in designs where one class monopolizes the processing, and other classes
primarily
encapsulate data. This AntiPattern is characterized by a class diagram composed of a single
complex
controller class surrounded by simple data classes. The key problem here is that the majority of the
responsibilities are allocated to a single class
Object Oriented Analysis and Design
Software Development Antipatterns – The Blob
Symptoms and Consequences
• Single class with a large number of attributes, operations, or both. A class with 60 or more
attributes and operations usually indicates the presence of the Blob.
• Adisparate collection of unrelated attributes and operations encapsulated in a single class.
An overall lack of cohesiveness of the attributes and operations is typical of the Blob.
• The Blob Class is typically too complex for reuse and testing. It may be inefficient, or
introduce excessive complexity to reuse the Blob for subsets of its functionality.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 70/77
• TheBlob Class may be expensive to load into memory, using excessive resources, even for
simple operations.
Object Oriented Analysis and Design
Software Development Antipatterns – The Blob
Typical Causes
• Lackof an object-oriented architecture.
• Lackof (any) architecture.
• Lackof architecture enforcement.
• Toolimited intervention.
• Specified disaster.
Object Oriented Analysis and Design
Software Development Antipatterns – The Blob
Refactored Solution
Step 1:
• Identify or categorize related attributes and operations according to contracts. These contracts
should be
cohesive in that they all directly relate to a common focus, behavior, or function within the overall
system.
Object Oriented Analysis and Design
Software Development Antipatterns – The Blob
Object Oriented Analysis and Design
Software Development Antipatterns – The Blob
Step 2:
• Look for "natural homes" for these contract-based collections of functionality and then migrate
them there. In this example, we gather operations related to catalogs and migrate them from the
LIBRARY class and move them to the CATALOG class.
Object Oriented Analysis and Design
Software Development Antipatterns – The Blob
• The third step is to remove all "far-coupled," or redundant,
indirect associations. In the example, the ITEM class is
initially far-coupled to the LIBRARY class in that each item
really belongs to a CATALOG, which in turn belongs to a
LIBRARY.
• Next, where appropriate, we migrate associates to derived
classes to a common base class. In the example, once the
far-coupling has been removed between the LIBRARY and
ITEM classes, we need to migrate ITEMs to CATALOGs,
• Finally, we remove all transient associations, replacing them
as appropriate with type specifiers to attributes and
operations arguments.
explain the above for newbie in depth and for newbie in depth and for newbie make
understandable
Here’s a complete beginner-friendly explanation of the OOAD AntiPatterns content you shared,
broken down by category and made as simple and understandable as possible.
🚨 Symptoms:
1. Product upgrades force your app to change too.
2. Promised features from the vendor are delayed or missing.
3. The product doesn’t follow standard rules (open systems).
4. If you miss an upgrade, you might need to buy it again and rebuild everything.
🔍 Causes:
1. Product does not follow standards because no one checks compliance.
2. Chosen based on sales talk, not real technical analysis.
3. Your app is too tightly connected to the product.
4. Developers need deep knowledge of the product.
5. Product is too complex compared to what your app needs.
Helps when the vendor product changes—you only update the isolation layer, not the entire app.
Gives a simpler, cleaner interface for developers.
Helps support multiple vendor systems if needed.
Makes your software flexible and future-proof.
🚨 Symptoms:
1. A class with 60+ methods/attributes—too much!
2. The class has unrelated features all mixed together.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 73/77
3. It’s too hard to reuse or test.
4. It’s slow and takes too much memory.
🔍 Causes:
No proper object-oriented design.
No real system architecture.
No one checks if the design stays clean.
Little intervention or guidance.
The system was destined to go wrong from the start.
Step 2:
Step 3:
Step 4:
Step 5:
Clean up any temporary connections. Use clean types and arguments instead.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 74/77
AntiPattern What It Is Why It Happens What to Do Instead
Vendor Lock-In Stuck with one vendor No standards, tight coupling Use an isolation layer
One class does
The Blob Bad design, no architecture Break it into smaller classes
everything
Would you like diagrams or visual mind maps for any of these patterns to make them easier to
remember?
Uploaded image
what is this called pronosed like what see image
The image you provided is a UML Class Diagram showing an association relationship between two
classes: `Student` and `Team`.
🔍 What It Shows:
The line connecting `Student` and `Team` represents an association named `membership`.
The numbers `1..*` on both ends mean:
A Student must belong to at least one Team and can belong to many.
A Team must have at least one Student, and can have many students.
This means it's a many-to-many relationship.
📚 Real-World Analogy:
Think of a college project:
A student might be part of multiple teams (e.g., tech club, sports team).
A team must have at least one student, but usually has several.
📘 Pronounced Like:
"Many-to-many association between Student and Team."
Would you like a Java or C++ code example of how to model this?
Aggregation
We can model objects that contain other objects by way of special associations called
aggregations and compositions. It is also known as “has a” relationship.
An aggregation specifies a whole-part relationship between an aggregate (a whole) and a
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 75/77
constituent part, where the part can exist independently from the aggregate. Aggregations are
denoted by a hollow-diamond adornment on the association.
Car
Person-owns: Book[ ]
Engine
Transmission
Book
1
*-owner: Person[ ]
One object A has or owns another object B, and/or B is part of
A. For example, suppose there are different Book objects for
different physical copies. Then the Person object has/owns the
Book object, and, while the book is not really part of the
person, the book is part of the person's property. In this case,
each book will (usually) have one owner. Of course, a person
might own any number of books.
Object Oriented Analysis and Design
Composition
A composition indicates a strong ownership and coincident lifetime of parts by the whole (i.e.,
they live and die as a whole). Compositions are denoted by a filled-diamond adornment on
the association.
1
Window
1
Scrollbar
1
1
1
1 ..*
Titlebar
Menu
Person-owns: Book[ ]
EBookwithDRM
1
*-owner: Person[ ]
In addition to an aggregation relationship, the
lifetimes of the objects might be identical, or near
For example, in an idealized world of electronic
books with DRM (Digital Rights Management), a
person can own an ebook, but cannot sell it. After
the person dies, no one else can access the ebook.
[This is idealized, but might be considered less than
ideal.
Difference table of them with examples and minimun 5 points check the refernce i have shared
Here’s a simple and clear difference table between Aggregation and Composition based on your
provided reference, with examples and 5+ points:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 76/77
Feature Aggregation ( 🟡 Hollow Diamond) Composition ( ⚫ Filled Diamond)
Definition Weak “has-a” relationship. Strong “has-a” relationship.
Lifetime Part can exist independently of the
Part cannot exist without the whole.
Dependency whole.
Symbol in UML
🟡 Hollow diamond at the ⚫ Filled diamond at the composite (whole) end.
aggregate (whole) end.
Shared ownership: parts may belong Exclusive ownership: part belongs to only one
Ownership
to multiple aggregates. composite.
Example from A `Person` owns `Book[]`: If a A `Person` owns `EBookWithDRM[]`: If person
Reference person dies, books still exist. dies, ebooks become inaccessible.
A `Car` has an `Engine` (can be A `Window` has a `Scrollbar` (dies with the
Real-life Example
removed and reused). window).
Code Analogy `class Person { Book[] books; `class Window { Scrollbar scrollbar =
(Java-like) }` new Scrollbar(); }`
🧠 Memory Trick:
Aggregation – A = Allow separate life. (Hollow heart 💛)
Composition – C = Cannot live without. (Filled heart ❤️)
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 77/77