business-logic-layer

Business Logic Layer And Why It Matters To Understand Blockchain Business Models

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.

Key takeaways:

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.

Read Next: Proof-of-stakeProof-of-workBitcoinEthereumBlockchain.

Main Free Guides:

Published by

Gennaro Cuofano

Gennaro is the creator of FourWeekMBA which reached over a million business students, executives, and aspiring entrepreneurs in 2020 alone | He is also Head of Business Development for a high-tech startup, which he helped grow at double-digit rate | Gennaro earned an International MBA with emphasis on Corporate Finance and Business Strategy | Visit The FourWeekMBA BizSchool | Or Get The FourWeekMBA Flagship Book "100+ Business Models"