Re:On over-engineering; finding the right balance
by mrkeen on Wednesday September 11, 2024 @05:57AM
(#41509796)
I think this is the common understanding of what 'abstraction' and 'generality' mean in the over-engineering sense, and I think it's wrong.
You make things more general/abstract/future-proof by removing things, not adding things.
ShoppingCart is a collection. We have libraries and libraries of code which work over collections. So List<Item> is better.
Once you start hacking on the various ShoppingCart-related methods a bit more, you'll probably realise you don't depend on Item. Many of those methods should start operating on List<A> instead. And then chances are they'll be pass-through methods that just forward the behaviour to some List implementation, at which point you can delete the passthrough methods, and directly call the List methods directly.
You make things more general/abstract/future-proof by removing things, not adding things.
ShoppingCart is a collection. We have libraries and libraries of code which work over collections. So List<Item> is better.
Once you start hacking on the various ShoppingCart-related methods a bit more, you'll probably realise you don't depend on Item. Many of those methods should start operating on List<A> instead. And then chances are they'll be pass-through methods that just forward the behaviour to some List implementation, at which point you can delete the passthrough methods, and directly call the List methods directly.