DEV Community

Discussion on: What Is Business Logic?

Collapse
6temes profile image
Daniel

It's easier to understand if you try to classify your code in two categories: business logic and infrastructure logic.

Business logic, as other people commented, is the logic that is defined by the business.

Infrastructure logic is the logic that makes your app work.

Ideally, you want to separate both logics as much as possible.

Some classes should ideally read like "if the customer buys 2 products or more, apply discount. If not, don't apply discount".

Others will read like "if the HTTP response from the remote API is not 201, wait x seconds and retry".

One code defines what your users want the application to do. The other code is needed to make your program work.

Obviously, the line sometimes is a bit blury, but you get the idea.

Collapse
tiffany profile image
Tiffany White Author

This is the clearest example for me. Thanks for explaining it like this.