restaurant-management-system
restaurant-management-system copied to clipboard
Code Smell and Refactoring
Hello, for student reasons I have looked for parts of your code where there may code smells and refactoring techniques can be applied.
In the CartItem and Cart classes you might get the stink of Inappropriate Intimacy because the getTotalPrice method is implemented in Cart but uses mostly information from CartItem
https://github.com/sopnopriyo/restaurant-management-system/blob/34a5024384d7b7d478aab41f313671cfcb7f8bf1/src/restaurantsystem/model/Cart.java#L36-L43
To fix this bad smell you can apply the move method technique with it the getTotalPrice method you could work directly in CartItem with the price of the Item and the amount it has.
Here is an example of a possible implementation: