Utilize Low-Code/No-Code Applications and Automations for Citizen Developers

Turning Business Rules Into Application Logic

Objectives
After completing this lesson, you will be able to:

After completing this lesson, you will be able to:

  • Convert business rules into application logic

Turning Business Rules into Application Logic

In this lesson, we’ll talk about the role of logic in an app. Logic is what makes your application actually do things. Logic is fundamentally based on the business rules, and the requirements for those should be well understood during the planning process. To ensure that business rules are appropriately met by the application, the supporting logic needs to be defined as a flow of events, actions, and functions. This flow can be simple or branching. It is powered by variables, or changing data, that impacts the user interface and experience.

Business Rules are Closely Related to Software Requirements

Let’s first briefly discuss business rules. Business rules are the specific ways of operating that arise from your business. For example, it might be a business rule in your organization that an expense report must have a unit code attached to it. Any app built to deal with expense reports would have to implement this business rule as well.

Business rules are closely related to software requirements. For example, in our note-taking app, we could have a software requirement that two notes can’t have the same name. This is only important because you need to be aware that requirements of the app typically come from either business rules relating to the business context, or functional requirements relating to the function of the app itself. All business rules applied to an app are, logically, also software requirements.

Developing the logic is a matter of applying all these rules and requirements to our application. The business and application specific logic are why we look into developing custom applications in the first place, so it makes sense this will be one of the most involved and time-consuming aspects of creating a new application.

Application Logic as a Flow of Events, Actions, and Functions

Having understood the role logic will play in our app, we can then look at how logic in applications is actually implemented.

In traditional development environments, logic is implemented with code and most of the code deals with the application logic.

On low-code/no-code platforms, logic is often implemented using visual programming techniques. This approach will present application logic as a flow of events and actions. For example, in our note-taking example, we could have a button that says Create new note. The logic flow for this button would then look like this:

  1. The user clicks a button.
  2. The app navigates to the note-taking view.

The actions in a logic flow can also be thought of as functions. Functions are the other type of logic we can have an application. A function is essentially a box in which you may put something, and then something may come out. If you’ve ever used formulas in a spreadsheet, you have used a function. As an example, let’s consider a really simple spreadsheet formula such as SUM().

With SUM(), we have a function that takes the input numbers and returns the sum of them. As another example, we could also have something not to do with math, such as OPENURL(‘sap.com’). Here, the function argument is a website address and it would navigate us to the sap.com website.

With application logic, we have two distinct, but closely connected, ideas. The first concept is a logic flow, which starts with an event and performs a number of actions or functions. Then, we have the function, which takes inputs and then returns some output. With some functions, such as the SUM() function, we can say the function performs a transformation on the data given to it, summing the numbers.

Putting this together, we can say that application logic, in most cases, either performs actions connected to events, or it performs transformation connected to data.

Anatomy and Branching of a Logic Flow

In this lesson, we'll continue on the topic of logic flows. With logic flows, we can create almost any kind of custom behavior in an app.

Let’s learn more logic flows by looking more closely at events and functions in a logic flow. An event in an application can be anything that happens. In our first example of a logic flow, the event that started the flow was the user clicking a button. However, we can have other types of events, such as doing something when a view or a page is opened.

If you remember, our note-taking app had a list of all the notes. This list needs to be stored somewhere and, when the application starts, we should have this data show it in the list view. Here’s how this might look in a logic flow:

Here, the logic flow is started by an event called on page load, which means that something happens when the page is entered. It is followed by a function called get a list of notes.

In application development, the logic will be largely driven by various events that may originate from the user or the app itself.

Logic flows can also be branching. Let’s say in our note-taking app, we should only be able to save a note if it has a title. For this we could have a logic flow such as:

The function to check the title length can have two outcomes and, therefore, our logic flow branches in two paths. Branching logic is one of the basic aspects of application development, and many of the business rules will be implemented with this type of approach.

Flows and Formula Functions to Create Custom Logic

Let’s spend a bit more time on formula type functions. We know that SUM() is a simple function that sums numbers. Let’s expand on that and say that we want to SUM two decimal numbers, but also round up the result to a whole number. In that case ,our formula looks something like:

ROUND( SUM( 1.1, 1.2 ) )

This is starting to look a bit like code, but it is easy in principle. With multiple levels of functions such as this, the inner-most functions are resolved first and their output becomes the input for the outer functions.

To make it easier to understand this, imagine it as a flow. If we laid out these two formula functions as a flow, it would have the input numbers 1.1 and 1.2 going into the SUM() function, with the result 2.3 going into the ROUND() function, finally giving us 2 as the result.

Logic flows and formula functions are both about creating custom in logic in our app. Logic flows are built around events and functions as actions. Formula functions work in terms of input and output values. By imagining formula functions as a flow, we can realize that both types of logic have a lot in common despite their initial appearance.

Variables as Symbols for Data that Changes

Having covered how logic works with flows and functions, let’s finish the logic topic by talking about variables. A variable is a symbol that works as a placeholder for something, such as a number or expression, that could change. The changing value of this variable may then change the logic flow.

Let’s start with a simple scenario. We have a button and would like to display how many times the user has clicked the button. How would we do this with a logic flow?

To count the number of clicks, we need to have a number that increases every time a new click happens. In application development, this number would be stored in something called a variable.

A variable is just some value we’re interested in storing, which will change over time. For this button-click counting task, we could have a variable called Clicks and we would start this variable with the value of 0.

We would construct the logic flow so that:

Code snippet
User clicks -> set clicks variable to "clicks" +1
Copy code

This increases the number in the variable by 1 for each click.

Variables can contain anything from numbers to text to much more complex data. Variables are typically only stored while the application remains active, and are reset when the application is shut down. They are used in any situation in application development when you have a piece of information that you’d like to recall at a later point in time in the application.

Some examples of variables in our note-taking app would be the content of the note title, the note text, and the list of notes in the listing view.

All of the variables in the application form the application state. The state is not something you can see, rather it’s the idea that all the combinations of all the different variables can be thought of as different application states. This idea will be useful to us when we next look at how UI connects with variables.

Bindings Connect Variables to User Interface Components

Having some data in a variable, how do we add that data to the UI? A variable is just a piece of information. It doesn’t have any display in the UI, so we need something else. That something is called a binding.

Let’s take another look at our click counter example. We want to display the number of clicks next to the button. For this, we should put a text component next to the button. For the text component, we would do something that, in app development, is known as a binding.

This binding creates a link between a piece of data, such as our clicks variable and will always update the UI automatically as the underlying data is updated. This is the way dynamic data is connected to the UI of the application.

Summary

In this lesson, we’ve covered the details about how business rules are then converted into application logic that in turn powers how the app behaves. In summary:

  • Logic is what makes your application actually do things.
  • Logic is fundamentally based on the business rules, and requirements for those should be well understood during the planning process.
  • To ensure that business rules are appropriately met by the application, the supporting logic needs to be defined as a flow of events, actions and functions.
  • This flow can be simple or branching. It is powered by variables, or changing data, which then impacts the user interface and experience.

Save progress to your learning plan by logging in or creating an account