The main point is how one defines logic. To give some examples:
- I wouldn't categorize a function getFullName() in a Person entity, which just concatenates some strings, as logic.
- Calculating an order item value would more likely qualify for being logic.
- Doing some booking transactions I would definitely say is logic.
Point 1 and maybe 2 would go for me into the entity. Point 3 not. So I define logic as:
- any operation that does any persistence related thing (read/write)
- any operation that involves any other (not directly related, e.g. master-detail) entity
IMO, any of these operations don't belong into entities.
Now, why/when I wouldn't put also point 1 and 2 type operations into an entity? It's a rather rare situation, but I wouldn't do it, as soon as the data stored in the entity needs to be interpreted in some way before it can be used by the application (e.g. if depending on current user, content of field X has a different meaning), that means the entity's data itself yields some logic.
answered 2009-01-23T18:29:42.717