-
Notifications
You must be signed in to change notification settings - Fork 131
Moueed Ali #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Moueed Ali #148
Conversation
|
The design follows a clear object-oriented approach with well-defined classes and responsibilities.
public class Bagel implements Item { ... }
|
|
The Problem with Inheritance Here A Customer is-a MemberPublic (inheritance relationship) All Customers automatically get all MemberPublic behaviors This creates several potential issues: Inheritance is rigid - What if you need a Customer that isn't a MemberPublic? Future changes become difficult - Changing MemberPublic affects all Customers Multiple roles problem - What if someone is both a Manager and Customer? Over-inheritance - Customers inherit all MemberPublic methods even if irrelevant Why Composition Works Better A Customer has-a MemberPublic (composition relationship) More flexible and maintainable design `public class MemberPublic { } public class Customer { }` |
|
I think there might have been a misunderstanding, probably because of my class diagram or domain model. But the idea I have is that they are distinct classes, so Customer and MemberPublic are their own classes, without anything in common. Can I just go with that approach? I don't quite understand why a customer needs to have an instance of MemberPublic. Is it just implying that a customer can also be a member of public? |
Yea, the idea is that a customer can also be a member of the public, and a manager can be a customer, etc. But we can stick with your approach of having unrelated classes |
… methods in some as well
|
Regarding the methods calculateTotalCostOfBasket and showCostOfItemBeforeAdding, are these methods that should be in the Basket class? Then let the customer call these methods from their class through a basket instance? |
calculateTotalCostOfBasket - I would put this in the basket c;lass |
…ss diagram and domain model
… and add some tests later
…s partially done.
No description provided.