Business logic dependent on model attribute
问题 I have a User model that has an introduced_by attribute. Based on that attributes value, I calculate my commission differently. What would be the best, most flexible way of doing this? Should I do a switch, or maybe put everything in a flat file? Also, should I create a Commission model? 回答1: It's a very broad question, as there is no code and no example. However, it seems to be the perfect case of a Strategy design pattern. What I would do, is to create a class that represents the strategy