Data-driven programming is a programming model characterized by program statements that describe the data instead of a sequence of actions. For example, an email filtering system may be programmed to block emails from malicious email addresses.
The code would only consist of a few lines, including a command that calls the database containing the list of malicious email addresses. The database will need to be updated regularly with new dangerous emails, but the email filtering program’s code will remain the same.
In contrast, some programming paradigms require developers to update the code every time data is added or updated.
Other interesting terms…
Read More about “Data-Driven Programming”
A program is usually made up of if-then statements. For example, an email filtering system may be designed to only accept messages from known email addresses. The code will be a series of if-then statements, such as:
- If the sender’s email address is user1@company[.]com, user2@company[.]com, user3@company[.]com, …, user100@company[.]com, user101@company[.]com, then accept the message.
- If the sender’s email address is not user1@company[.]com, user2@company[.]com, user3@company[.]com, …, user100@company[.]com, user101@company[.]com, then block the message.
If there are new company email users, their email addresses have to be added to the code. Data-driven programming works differently, and we explain this concept simply below.
How Does Data-Driven Programming Work?
The concept behind data-driven programming is simple. Instead of hard-coding the steps a program needs to execute, the developer designs the program so that the data will dictate the program’s actions.
In the email filtering system described above, data-driven programming would require a separate file containing all company users’ email addresses. The code will not be a series of if-then statements. Instead, it will contain a command that tells the system to refer to the file or database. If the email filtering system finds the sender’s email address in the database, it permits the message to go through the network. If not, it blocks the message.
When a new user arrives or an email address has to be removed, the administrator would only have to update the database. There won’t be any need to update the code.
What Are the Advantages and Disadvantages of Data-Driven Programming?
One of the benefits of data-driven programming is that it keeps coding simple since there’s no need to modify the code to accommodate data changes. As a result, integrations also become straightforward.
Systems can be integrated into other solutions without complications brought about by constant code modifications. Take note that every time there’s a change to the code, it has to go through standard testing to ensure the integrity and quality of the software.
Another advantage of using the data-driven programming model is that it unifies all artifacts in one space. Datasets, statistics, and other data are stored in one system, removing confusion.
Data-driven programming also has its downsides, which primarily have to do with data handling. When data is wrongly defined or grouped, it would also result in erroneous execution.
What Are Some Examples of Data-Driven Programming Languages?
Programming languages that support data-driven programming include:
- AWK
- BASIC
- Clojure
- FDM
- Lua
- maildrop
- Oz
- Perl
- procmail
- sed
- Sieve
- Tab
What Is the Difference between Data-Driven and Event-Driven Programming?
In data-driven programming, the data triggers the flow of the program. On the other hand, the event-triggered programming model executes steps depending on events.
The event could be a message sent from other programs, a sensor trigger, or a user action, such as a key press or a mouse click. Unlike data-driven programming, event-driven programming can generally be applied using any programming language.
What Is the Difference between Data-Driven and Object-Oriented Programming?
Object-oriented programming is a programming paradigm based on objects or units of code that can contain a collection of data, functions, and methods. Computer systems or applications designed using object-oriented programming have objects interacting with one another. As such, task executions are triggered by objects. In contrast, data-driven programs are designed based on data.
—
Data-driven programming is only one of the many programming models available. Some of them aren’t mutually exclusive, meaning you can design a computer program using both data-driven and event-driven or other programming paradigms.