0% found this document useful (0 votes)
8 views2 pages

Sda Assignment1

Uploaded by

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

Sda Assignment1

Uploaded by

raozeeshanhafiz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Scenario: Food Delivery App

The app has customers, restaurants, orders, and delivery persons.

✅ 1. Information Expert

Rule: Give responsibility to the one who has the data.

Example:
The Order class knows the food items, price, and order time — so it calculates the total price.

✅ 2. Creator

Rule: A class should create objects it is connected to.

Example:
The Restaurant class creates MenuItem objects because it owns the menu.

✅ 3. Controller

Rule: A controller handles user input and system commands.

Example:
The AppController class receives the "Place Order" click and tells Order and Payment what to
do.

✅ 4. Low Coupling

Rule: Keep classes separate so changes don’t break other parts.

Example:
Customer class doesn’t directly contact DeliveryPerson — it only talks to the AppController.

✅ 5. High Cohesion
Rule: A class should only do related tasks.

Example:
DeliveryPerson only handles delivery (pickup, route, deliver) — not payment or food details.

✅ 6. Polymorphism

Rule: Same method name works for different types.

Example:
CreditCardPayment and CashPayment both have a method makePayment(), but the process is
different inside.

✅ 7. Pure Fabrication

Rule: Create a helper class that doesn't exist in real life.

Example:
InvoicePrinter class only prints bills. It’s not a real-world object, but helps organize the code.

✅ 8. Indirection

Rule: Add a middle class to help two others connect.

Example:
OrderManager handles the link between Customer and Restaurant, so they don’t talk directly.

You might also like