Skip to content

Code Smell and Refactoring  #2

@carana08

Description

@carana08

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

public double getTotalPrice() {
totalPrice = 0;
cartItems.forEach((cartItem) -> {
totalPrice += cartItem.getPrice();
});
return totalPrice;
}

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:
image
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions