In programming, the Business Logic Layer (BLL) serves as an intermediary for data exchange between the presentation layer and the Data Access Layer (DAL). The Business Logic Layer handles the business rules, calculations, and logic within an application which dictate how it behaves. That is, the BLL determines how data from the database is used and what it can and cannot do within the application itself.
Understanding a Business Logic Layer
In this way, the Business Logic Layer manages communication between the database and the presentation layer – sometimes referred to as the end-user interface. It forms part of the multi-tier architecture of software engineering where various functions are physically separated.
Separation typically involves functions assigned to one of three layers:
- User Interface Layer (UI) – where all presentation and user interaction occurs. Data is displayed to the user. The user sends and also receives data.
- Business Logic Layer (BLL) – as we have noted, the BLL deals with application processing and coordinates the flow of data between the UI and DAL.
- Data Access Layer (DAL) – or the layer where data management takes place. In most cases, this is via a web service or database.
Defining a Business Logic Layer
Both the UI and DAL are relatively easy to define and understand. However, there is less clarity on what constitutes a BLL. As a result, many businesses (including Apple and Microsoft) exclude the BLL from their applications entirely and have UI code communicate directly with the DAL.
In coding, this leads to what is colloquially called the “Fat Controller”. This describes a controller with domain logic servicing too many requests. In turn, controller logic becomes overly complex and too dependent on domain concepts. Ultimately, this complexity makes code maintenance difficult.
A better option is to design the application to support multiple different user interfaces. Code that is common to each user interface then becomes the Business Logic Layer.
Generally speaking, this code is any which deals with the following:
- Persisting data (to the DAL).
- Displaying data (to the UI layer).
- Accessing data (from the DAL).
- Making logical decisions.
- Performing calculations.
- Maintaining application state.
- Coordinating workflow.
- Processing commands (from the UI layer).
Used properly, the BLL centralizes as much common logic as possible and is not tied to a particular UI. This enables the application to support any number of user interfaces and minimizes instances of code duplication.
It’s also important to note that the code in the UI layer must necessarily shrink as it grows in the BLL. This concept is central to the “Thin Controller” theory.
As the BLL grows and starts to become bloated, the layer can be separated further by moving from a three-tier to an n-tier architecture.
A Business Logic Layer serves as an intermediary for data exchange between the Data Access Layer (DAL) and the User Interface Layer (UI).
Finding it too difficult to define, many businesses omit the Business Logic Layer completely. With the DAL communicating directly with the UI, code becomes overly complex and maintenance problematic.
A Business Logic Layer allows developers to design applications that support multiple user interfaces. This minimizes the chances of needless code duplication.
Main Free Guides: