Re:Inheritance Is Terrible
by nitwit005 on Saturday March 19, 2016 @05:43PM
(#11320608)
I get the point being made, but the rules probably shouldn't be directly associated with the Item objects in the first place. How would you apply a pricing rule like: "Free shipping if item total is > $20 after discounts applied"?
The general approach I've seen to this sort of thing is to create a stack of rules, and each rule applies its changes if needed. And for that, an array of function pointers will work fine.
The general approach I've seen to this sort of thing is to create a stack of rules, and each rule applies its changes if needed. And for that, an array of function pointers will work fine.