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. 

AspectExplanation
DefinitionThe Business Logic Layer, often referred to as the “Business Layer” or “Business Logic,” is a crucial component in software architecture and application development. It represents the core logic and rules that govern the operations, processes, and behavior of a software application. This layer is responsible for implementing the business rules, workflows, calculations, and decision-making processes that drive the functionality of the software. It acts as an intermediary between the presentation layer (user interface) and the data layer (database), ensuring that business operations are executed correctly and consistently. The Business Logic Layer plays a pivotal role in maintaining the integrity of data and enforcing business-specific rules and requirements.
Key ConceptsBusiness Rules: The predefined rules and policies that guide the behavior and decision-making within an organization or application. – Workflow: The sequence of steps or actions that define how a specific business process is carried out. – Validation: The process of verifying and validating data and inputs according to business rules. – Data Transformation: Converting and processing data to align with the requirements of the business logic. – Authorization: Determining access rights and permissions based on user roles and privileges. – Scalability: The ability of the Business Logic Layer to handle increased loads and growing business requirements.
CharacteristicsCentralized Logic: The Business Logic Layer consolidates and centralizes the core logic of an application. – Independence: It is designed to be independent of the user interface and data storage mechanisms, promoting modularity and flexibility. – Data Integrity: Ensures data consistency and adherence to business rules, preventing erroneous or unauthorized data changes. – Complex Processing: Capable of performing complex calculations, decision-making, and processing tasks. – Reusable Components: Business logic components can often be reused across different parts of an application or in other applications. – Security: Implements security measures such as authentication and authorization to protect sensitive business operations and data.
ImplicationsConsistency: Ensures that business rules and processes are consistently applied throughout the application. – Data Integrity: Protects the integrity of data by enforcing validation and business rules. – Scalability Challenges: As the application grows, the Business Logic Layer may face scalability challenges due to increased processing demands. – Maintenance: Frequent updates or changes to business rules may require ongoing maintenance of the Business Logic Layer. – Security Enforcement: Implements security measures to prevent unauthorized access and actions within the application. – Interoperability: May interact with external systems and services for specific business processes.
AdvantagesSeparation of Concerns: Separating business logic from the user interface and data storage enhances maintainability and flexibility. – Reusability: Business logic components can be reused in multiple parts of the application or across different applications. – Consistency: Ensures consistent application of business rules and processes, reducing errors and inconsistencies. – Modifiability: Easier to modify or update business rules without affecting the entire application. – Security: Enforces security measures to protect sensitive data and operations. – Scalability: Scales to handle increased user loads and growing business requirements.
DrawbacksComplexity: Developing and managing the Business Logic Layer can be complex, especially for large and intricate applications. – Maintenance: Frequent changes to business rules may require ongoing maintenance efforts. – Performance Impact: Complex business logic can impact application performance, requiring optimization. – Dependency: The application’s functionality relies heavily on the correctness and performance of the Business Logic Layer. – Testing Challenges: Comprehensive testing is necessary to ensure the correct functioning of business logic components. – Integration Complexity: Interactions with external systems or services can introduce integration complexities.
ApplicationsThe Business Logic Layer is a fundamental component in various types of software applications, including web applications, mobile apps, enterprise systems, and e-commerce platforms. It is particularly essential in applications where business rules, workflows, and data validation play a critical role in achieving the application’s objectives.
Use CasesE-commerce Platform: Manages pricing, inventory, order processing, and payment processing rules. – Customer Relationship Management (CRM) Software: Implements sales workflows, lead management, and customer data validation. – Financial Systems: Enforces financial calculations, transaction processing, and compliance rules. – Healthcare Applications: Handles patient data, treatment plans, and medical record validation. – Enterprise Resource Planning (ERP) Systems: Orchestrates business processes such as supply chain management, human resources, and accounting. – Gaming Applications: Implements game mechanics, scoring, and rules governing gameplay.

Understanding a business logic layer

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. 

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 multitier architecture of software engineering where various functions are physically separated.

Separation typically involves functions assigned to one of three layers:

  1. User interface (UI) layer – where all presentation and user interaction occurs. Data is displayed to the user. The user sends and also receives data.
  2. 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.
  3. Data access layer (DAL) – or the layer where data management takes place. In most cases, this is via a web service or database.

Collectively, each of the three layers plays an integral role in many web applications. Consider the example of an insurance website that features an application where consumers can view their insurance policies. 

The consumer’s browser interacts with the application’s user interface layer code, with customer policy data held in the data access layer. The BLL is the most important component since it contains any important calculations or business logic and ultimately, determines whether the consumer is entitled to obtain insurance cover.

Differentiating between business logic and business rules

Business logic sets out how business objects interact with each other and enforces how these objects are updated and accessed. Logic decides how data is transformed, calculated, and sent to workflows, which are the ordered tasks one participant (user, software) sends to another.

Business rules, on the other hand, are formal expressions of “real-world” business policy, such as those relating to loans, accounts, and itineraries. 

To explain the difference more succinctly, it can be helpful to remember that any procedure or process falls under the business logic banner. Any factor that is neither of these can be considered a business rule. 

When a consumer visits an eCommerce website, for example, business logic defines a workflow where the consumer can add a product to their cart, enter their postal address, provide their credit card details, and land on a confirmation page. An example of a business rule in this process may describe a particular method for communicating with the VisaNet electronic payments network.

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:

  1. Persisting data (to the DAL).
  2. Displaying data (to the UI layer).
  3. Accessing data (from the DAL).
  4. Making logical decisions.
  5. Performing calculations.
  6. Maintaining application state.
  7. Coordinating workflow.
  8. 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 worth noting 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.

Benefits of business logic layers

Business logic layers are a recommended software engineering convention. Together with the user interface and data access layers, this multitier architecture has important implications for code reusability and modular design

To that end, there are several benefits to adopting the compartmentalized approach:

  1. Code maintenance – as we touched on briefly in the previous section, multitier architecture makes code maintenance much easier. When a business requirement changes, the associated business logical layer is often the only component that requires code to be altered. By the same token, it can be very difficult to determine where in the application a code change should be made if there is no compartmentalization whatsoever. 
  2. Application releases – another benefit of the business logic layer and multitiered architecture is the ease with which application releases can be rolled out. It stands to reason that if the BLL was the only layer to be updated, then it is the only one that should be used in the production environment. That is, the user interface layer and data access layer can be left alone and remain unaltered.
  3. Ease of learning – development teams may also benefit from the BLL and multitier architecture approach. Individual employees need only specialize in presentation development, data, or business logic skills to more rapidly learn their specific part of the application. This also has positive implications for efficiency. Since each layer can be worked on at the same time, the development timeframe becomes shorter.

Key takeaways:

  • A business logic layer serves as an intermediary for data exchange between the data access layer (DAL) and the user interface (UI) layer.
  • 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.

Related Blockchain Business Frameworks

Web3

web3
Web3 describes a version of the internet where data will be interconnected in a decentralized way. Web3 is an umbrella that comprises various fields like semantic web, AR/VR, AI at scale, blockchain technologies, and decentralization. The core idea of Web3 moves along the lines of enabling decentralized ownership on the web.

Blockchain Protocol

blockchain-protocol
A blockchain protocol is a set of underlying rules that define how a blockchain will work. Based on the underlying rules of the protocol it’s possible to build a business ecosystem. Usually, protocol’s rules comprise everything from how tokens can be issued, how value is created, and how interactions happen on top of the protocol.

Hard Fork

hard-fork
In software engineering, a fork consists of a “split” of a project, as developers take the source code to start independently developing on it. Software protocols (the set of rules underlying the software) usually fork as a group decision-making process. All developers have to agree on the new course and direction of the software protocol. A fork can be “soft” when an alteration to the software protocol keeps it backward compatible or “hard” where a divergence of the new chain is permanent. Forks are critical to the development and evolution of Blockchain protocols.

Merkle Tree

merkle-tree
A Merkle tree is a data structure encoding blockchain data more efficiently and securely. The Merkle tree is one of the foundational components of a Blockchain protocol.

Nothing-at-stake

nothing-at-stake-problem
The nothing-at-stake problem argues that validators on a blockchain with a financial incentive to mine on each fork are disruptive to consensus. Potentially, this makes the system more vulnerable to attack. This is a key problem that makes possible underlying blockchain protocols, based on core mechanisms like a proof-of-stake consensus, a key consensus system, that together the proof-of-work make up key protocols like Bitcoin and Ethereum.

51% Attack

51%-attack
A 51% Attack is an attack on the blockchain network by an entity or organization. The primary goal of such an attack is the exclusion or modification of blockchain transactions. A 51% attack is carried out by a miner or group of miners endeavoring to control more than half of a network’s mining power, hash rate, or computing power. For this reason, it is sometimes called a majority attack. This can corrupt a blockchain protocol that malicious attackers would take over.

Proof of Work

proof-of-work
A Proof of Work is a form of consensus algorithm used to achieve agreement across a distributed network. In a Proof of Work, miners compete to complete transactions on the network, by commuting hard mathematical problems (i.e. hashes functions) and as a result they get rewarded in coins.

Application Binary Interface

application-binary-interface
An Application Binary Interface (ABI) is the interface between two binary program modules that work together. An ABI is a contract between pieces of binary code defining the mechanisms by which functions are invoked and how parameters are passed between the caller and callee. ABIs have become critical in the development of applications leveraging smart contracts, on Blockchain protocols like Ethereum.

Proof of Stake

proof-of-stake
A Proof of Stake (PoS) is a form of consensus algorithm used to achieve agreement across a distributed network. As such it is, together with Proof of Work, among the key consensus algorithms for Blockchain protocols (like the Ethereum’s Casper protocol). Proof of Stake has the advantage of security, reduced risk of centralization, and energy efficiency.

Proof of Work vs. Proof of Stake

proof-of-work-vs-proof-of-stake

Proof of Activity

proof-of-activity
Proof-of-Activity (PoA) is a blockchain consensus algorithm that facilitates genuine transactions and consensus amongst miners. That is a consensus algorithm combining proof-of-work and proof-of-stake. This consensus algorithm is designed to prevent attacks on the underlying Blockchain.

Blockchain Economics

blockchain-economics
According to Joel Monegro, a former analyst at USV (a venture capital firm) the blockchain implies value creation in its protocols. Where the web has allowed the value to be captured at the applications layer (take Facebook, Twitter, Google, and many others). In a Blockchain Economy, this value might be captured by the protocols at the base of the blockchain (for instance Bitcoin and Ethereum).

Blockchain Business Model Framework

blockchain-business-models
A Blockchain Business Model is made of four main components: Value Model (Core Philosophy, Core Value and Value Propositions for the key stakeholders), Blockchain Model (Protocol Rules, Network Shape and Applications Layer/Ecosystem), Distribution Model (the key channels amplifying the protocol and its communities), and the Economic Model (the dynamics through which protocol players make money). Those elements coming together can serve as the basis to build and analyze a solid Blockchain Business Model.

Sharding

sharding
Blockchain companies use sharding to partition databases and increase scalability, allowing them to process more transactions per second. Sharding is a key mechanism underneath the Ethereum Blockchain and one of its critical components. Indeed, sharding enables Blockchain protocols to overcome the Scalability Trilemma (as a Blockchain grows, it stays scalable, secure, and decentralized).

DAO

decentralized-autonomous-organization
A decentralized autonomous organization (DAO) operates autonomously on blockchain protocol under rules governed by smart contracts. DAO is among the most important innovations that Blockchain has brought to the business world, which can create “super entities” or large entities that do not have a central authority but are instead managed in a decentralized manner.

Smart Contracts

smart-contracts
Smart contracts are protocols designed to facilitate, verify, or enforce digital contracts without the need for a credible third party. These contracts work on an “if/when-then” principle and have some similarities to modern escrow services but without a third party involved in guaranteeing the transaction. Instead, it uses blockchain technology to verify the information and increase trust between the transaction participants.

Non-Fungible Tokens

non-fungible-tokens
Non-fungible tokens (NFTs) are cryptographic tokens that represent something unique. Non-fungible assets are those that are not mutually interchangeable. Non-fungible tokens contain identifying information that makes them unique. Unlike Bitcoin – which has a supply of 21 million identical coins – they cannot be exchanged like for like.

Decentralized Finance

decentralized-finance-defi
Decentralized finance (DeFi) refers to an ecosystem of financial products that do not rely on traditional financial intermediaries such as banks and exchanges. Central to the success of decentralized finance is smart contracts, which are deployed on Ethereum (contracts that two parties can deploy without an intermediary). DeFi also gave rise to dApps (decentralized apps), giving developers the ability to build applications on top of the Ethereum blockchain.

History of Bitcoin

history-of-bitcoin
The history of Bitcoin starts before the 2008 White Paper by Satoshi Nakamoto. In 1989 first and 1991, David Chaum created DigiCash, and various cryptographers tried to solve the “double spending” problem. By 1998 Nick Szabo began working on a decentralized digital currency called “bit gold.” By 2008 the Bitcoin White Paper got published. And from there, by 2014, the Blockchain 2.0 (beyond the money use case) sprouted out.

Altcoins

altcoin
An altcoin is a general term describing any cryptocurrency other than Bitcoin. Indeed, as Bitcoin started to evolve since its inception, back in 2009, many other cryptocurrencies sprouted due to philosophical differences with the Bitcoin protocol but also to cover wider use cases that the Bitcoin protocol could enable.

Ethereum

ethereum-blockchain
Ethereum was launched in 2015 with its cryptocurrency, Ether, as an open-source, blockchain-based, decentralized platform software. Smart contracts are enabled, and Distributed Applications (dApps) get built without downtime or third-party disturbance. It also helps developers build and publish applications as it is also a programming language running on a blockchain.

Ethereum Flywheel

blockchain-flywheel
An imaginary flywheel of the development of a crypto ecosystem, and more, in particular, the Ethereum ecosystem. As developers join in and the community strengthens, more use cases are built, which attract more and more users. As users grow exponentially, businesses become interested in the underlying ecosystem, thus investing more in it. These resources are invested back in the protocol to make it more scalable, thus reducing gas fees for developers and users, facilitating the adoption of the whole business platform.

Solana

solana-blockchain
Solana is a blockchain network with a focus on high performance and rapid transactions. To boost speed, it employs a one-of-a-kind approach to transaction sequencing. Users can use SOL, the network’s native cryptocurrency, to cover transaction costs and engage with smart contracts.

Polkadot

polkadot-token
In essence, Polkadot is a cryptocurrency project created as an effort to transform and power a decentralized internet, Web 3.0, in the future. Polkadot is a decentralized platform, which makes it interoperable with other blockchains.

Filecoin

filecoin
Launched in October 2020, Filecoin protocol is based on a “useful work” consensus, where the miners are rewarded as they perform useful work for the network (provide storage and retrieve data). Filecoin (⨎) is an open-source, public cryptocurrency and digital payment system. Built on the InterPlanetary File System.

Brave

bat-token
BAT or Basic Attention Token is a utility token aiming to provide privacy-based web tools for advertisers and users to monetize attention on the web in a decentralized way via Blockchain-based technologies. Therefore, the BAT ecosystem moves around a browser (Brave), a privacy-based search engine (Brave Search), and a utility token (BAT). Users can opt-in to advertising, thus making money based on their attention to ads as they browse the web.

Decentralized Exchange

decentralized-exchange-platforms
Uniswap is a renowned decentralized crypto exchange created in 2018 and based on the Ethereum blockchain, to provide liquidity to the system. As a cryptocurrency exchange technology that operates on a decentralized basis. The Uniswap protocol inherited its namesake from the business that created it — Uniswap. Through smart contracts, the Uniswap protocol automates transactions between cryptocurrency tokens on the Ethereum blockchain.

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

Discover more from FourWeekMBA

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
FourWeekMBA