How do you handle domain logic that spans multiple model objects in an ORM?

Posted by duality_ on Programmers See other posts from Programmers or by duality_
Published on 2014-05-26T12:36:16Z Indexed on 2014/05/26 22:00 UTC
Read the original article Hit count: 227

Filed under:
|
|
|

So I know that business logic should be placed in the model. But using an ORM it is not as clear where I should place code that handles multiple objects.

E.g. let's say we have a Customer model which has a type of either sporty or posh and we wanted to customer.add_bonus() to every posh customer. Where would we do this? Do we create a new class to handle all this? If yes, where do we put it (alongside all the other model classes, but not subclass it from the ORM?)?

I'm currently using django framework in python, so specific suggestions are even more wanted.

© Programmers or respective owner

Related posts about orm

Related posts about django