educative.io

Business Logic meaning

When you say Business Logic, what do you mean by it? Also, I wanted to know more about Business Logic and Business layer.

Hi @bhaumik,

Hope you are doing well!

Business logic is a logic that you implement to fulfill a business need. A business logic is something that says “a user can place only a single order at time”. If you think about it, could you implement a system that can handle more than one order per client? Sure… you can use threads, queues, etc… But the Business (the owner of the company) says he wants to handle only one order per time.
It is important to note here, that a Business logic can (and probably will) change over time. If the business get bigger, the owner can ask you… “now, we can handle two orders per client in our app”. Saying that that’s the reason why:

  1. The architecture of a system must be able to add new features and change over time - as a business do (refer to books like “Clean Code” and “Clean Architecture” for how to keep your eyes in this)
  2. Not always a business rule can be implemented, due to the lack of technology or lack of engineering team,… So, it is important to know when something can or can not be build.

And, finally, the Business Layer is just a fancy name to any code related to the Business Rule. In a good system architecture, you should be able to change anything in Business Layer without need to change things in your Database (data layer) for example… In a perfect world everything is decoupled and changes in one layer doesnt affect other layers.

Hope that helps!

Att.
Artur Baruchi
(Twitter @abaruchi)