DEV Community

loading...

Explain business logic like i'm 5

Saurabh Sharma
Web development React.js GraphQL Typescript JavaScript Design SEO
・1 min read

Discussion (4)

Collapse
nestedsoftware profile image
Nested Software • Edited

Business logic is the code that implements the business rules for an application.

I tend to think of it as the "core" logic of an application. If you remove the code that is about how the user interacts with the application, (presentation logic), and you remove the code that has to do with I/O more generally (like persistence logic for example), the business logic is what is left over.

I use the term business logic even for non-business software. For instance, let's say you're building a video game, like pacman. The business logic would include things like the hunting strategies that the different ghosts use; how they behave when pacman activates a power pellet, or when they get eaten by pacman; the basic layout of each maze expressed as a data structure; score tracking; how many lives pacman starts with; what it takes to get an extra life, etc.

The business logic would not include the code that actually handles the joystick input, nor would it include the code that actually displays and animates the game.

In the original pacman game code from the 1980s, I suspect that the business logic code and all of the other code was probably mixed together, because computers in those days had very little memory and cpu. Nowadays, maintainability is more important, so we usually try to create separate modules of code across different concerns. So we'd have a module just for the business logic, then we'd have a separate module that handles the input, graphics, and animation.

Collapse
steelwolf180 profile image
Max Ong Zong Bao • Edited

"There is only one valid definition of business purpose: to
create a customer" Peter F Drucker

Everything surrounds it is to create a customer or maintain a great relationship with your customers who use your product or services.

It is the people who pay you directly or indirectly.

Collapse
michaeltd profile image
michaeltd

You run a financial institution which issues bonds to investors.

The formula: assets / bonds = price is your business logic.

Collapse
rhymes profile image
rhymes

Everything that makes you, you