Hacker News new | ask | show | jobs
by dennisgorelik 2042 days ago
It is better not to put business logic into data model - in order to:

1) Keep your business logic simpler.

2) Keep your data model simpler.

If you put both business logic and data model in the same class, then:

- When you investigate data references pointing to your class -- you will see references noise from your business logic.

- When you investigate business logic references pointing to your class -- you will see references noise from your data model.

3) Combined "business logic + data model" class is much harder to refactor.

So, technically, you can combine business logic and data model in the same class.

But practically, such code combining will significantly complicate maintainability of your code.