Reusability is a hallmark of good OOP code, which I hope this example demonstrates. The basis of the shopping cart is a class that only requires each item to have a getId() method. It doesn’t even matter what that method returns, so long as it’s a unique identifier for each item. From this foundation, custom item objects can be created, added to the cart, updated in the cart, and removed from the cart as needed. And the cart’s contents can be quickly counted and iterated over. Quite a lot of practical functionality that is easy to use in your next OOP-based e-commerce project!