101

I've been tasked at work to write a detailed engineering plan for a logistics application that we are coding to propose to a customer. I have been told that it is a data-driven application. What does it mean for an application to be "data-driven"? What is the opposite? I can't seem to get any really clear answer for this although while web searching I can see many people posting their own examples. Any help would be greatly appreciated.

alain.janinm
  • 19,035
  • 10
  • 56
  • 103
jtbradle
  • 2,190
  • 6
  • 22
  • 26
  • 2
    Pretty much all real world programming is data-driven. – Martin Spamer Nov 08 '12 at 15:44
  • 17
    The classic *The Art of Unix Programming* has an good discussion of this topic: http://homepage.cs.uri.edu/~thenry/resources/unix_art/ch09s01.html. Key quote: "In data-driven programming, the data is not merely the state of some object, but actually **defines the control flow of the program**. Where the primary concern in OO is encapsulation, the primary concern in data-driven programming is **writing as little fixed code as possible**." – FMc Jul 13 '13 at 21:43
  • 3
    FMc's answer is for me the most convincing explanation, and should be an answer, but elaborated. – Mads Skjern May 24 '15 at 07:38

8 Answers8

102

Data driven progamming is a programming model where the data itself controls the flow of the program and not the program logic. It is a model where you control the flow by offering different data sets to the program where the program logic is some generic form of flow or of state-changes.

For example if you have program that has four states: UP - DOWN - STOP - START

You can control this program by offering input (data) that represents the states:

  • set1: DOWN - STOP - START - STOP - UP - STOP
  • set2: UP - DOWN - UP - DOWN

The program code stays the same but data set (which is not of a dynamic input type but statically given to the computer) controls the flow.

nojevive
  • 3,238
  • 3
  • 20
  • 18
  • 3
    The programming part is writing/defining the "generic form of flow or of state-changes", am I right? But I can write such a "machine" in any language, and there is nothing unusual about that, so I don't really get anything out of your answer. Perhaps data-driven programming is when the language itself or a library, encourages or makes it very easy to write such machines. Or maybe the definition is that the language/library let's one define the machines in a declarative way, ie not procedural. – Mads Skjern May 24 '15 at 07:36
  • 2
    On https://en.wikipedia.org/wiki/Data-driven_programming, they use AWK as an example. In AWK two things are supplied, an expression defining what to be done with the data, and the data itself. What is the expression defining what to happen considered to be: 1) the programming, or 2) data. If it's considered to be data, then the programming is AWK's machine itself, which of course in the example of AWK is static. But in other contexts, eg if writing the machine itself in some traditional procedural way, that alone is the programming part. – Mads Skjern May 24 '15 at 07:46
  • So... assuming more powerful data drive programming examples are turing complete, does this not simply become an include statement in an engine with some pre-built assumptions and tools? – ZirconCode Mar 06 '20 at 11:09
57

Although there are more than a few ideas as to what data driven programming is, allow me to give an example using a data structure and a function.

Non data driven example:

data_lloyd = {'name': 'Lloyd', 'lives': 'Alcoy }
data_jason = {'name': 'Jason', 'lives': 'London' }
go = function(x) 
    if x.name == 'Lloyd' 
    then 
        print("Alcoy, Spain") 
    else 
        print("London, UK") 
end

Data driven example:

data_lloyd = {'name': 'Lloyd', 'lives': function(){ print("Alcoy, Spain") }
data_jason = {'name': 'Jason', 'lives': function(){ print("London, UK") }
go = function(x)
    x.lives()
end

In the first example the decision to show one result or the other is in the code logic. In the last example the output is determined by the data that is passed to the function and for that reason we say the output is 'driven' by the data.

imgx64
  • 3,715
  • 5
  • 22
  • 43
Lloyd Moore
  • 2,939
  • 28
  • 29
  • 3
    I know this is a simple example, but the non-data-driven example just looks like an example of sloppy coding. Does data-driven just mean good coding practices? If so, why would anyone want to pursue a non-data-driven approach? – Jin Jul 22 '18 at 21:00
  • 4
    I am sorry, but the first example looks like functional programming (where data and behavior is decoupled), and the second example looks like object oriented (where data and behavior is coupled). – Vakey Oct 01 '18 at 17:30
47

"I have been told that it is a data-driven application" - you need to ask whoever told you that.

You don't want to read some plausible answer here and then find out that it's not at all what the person in charge of your project meant. The phrase is too vague to have an unambiguous meaning that will definitely apply to your project.

RichieHindle
  • 244,085
  • 44
  • 340
  • 385
  • 8
    I understand what you mean Richie, and that is a good point. However, I was wondering if "data-driven programming" was some sort of term concretely recognized by the software development industry. I won't take any answer from here simply at face value here without checking back with my boss. -Thanks :) – jtbradle Jun 30 '09 at 19:46
  • 5
    Sure - you were right to ask here. But I think the answer is that there is no universally accepted definition. – RichieHindle Jun 30 '09 at 19:56
  • 1
    What is it called when you generate your UX from meta-data? What is it called when your workflow is controlled by an external configuration? Is that Data Driven Architecture and Event Driven Architecture? Would Data Driven Programming be more akin to WSDL and GraphQL where your models are generated but you still code against them however you see fit? – Corey Alix May 19 '20 at 15:12
15

Data driven development is something that one can make changes to the logic of the program by editing not the code but the data structure.

You might find more information about data-driven programming here.

Procedural Programming

var data = { 
            {do:'add',arg:{1,2}},
            {do:'subtract',arg:{3,2}},
            {do:'multiply',arg:{5,7}},
            };

foreach(var item in data){  
    switch(item.do){
        case 'add':
            console.log(item.arg[0] + item.arg[1]);
        break;
        case 'subtract':
            console.log(item.arg[0] - item.arg[1]);
        break;
        case 'multiply':
            console.log(item.arg[0] * item.arg[1]);
        break;
    }
}

Data Driven Programming

var data = { 
            {do:'+',arg:{1,2}},
            {do:'-',arg:{3,2}},
            {do:'*',arg:{5,7}},
            };

foreach(var item in data){      
    console.log(eval (item.arg[0] + item.do + item.arg[1]);
}
Ryan M
  • 11,512
  • 21
  • 38
  • 50
  • 2
    @delrocco Thanks for noticing the dead link! In the future, you can go to the [Internet Archive](http://web.archive.org/) to find old copies of web pages like this. I've gone ahead and restored the link to this post using that. – Ryan M Dec 09 '20 at 10:36
8

Data driven application is:

(1) a set of rules accepting different data sets to make a predetermined decision for each specific data set and throwing outcome as result

(2) a few predetermined processes that are triggered based on the outcome.

Perfect example is ifttt.com

The application has nothing but rules. What makes it useful is the data that will flow through it.

Jens
  • 61,963
  • 14
  • 104
  • 160
Vivek
  • 81
  • 1
  • 1
4

This article explains most clearly what I understand the term to mean:

What is Table-Driven and Data-Driven Programming? http://www.paragoncorporation.com/ArticleDetail.aspx?ArticleID=31

Data/Table-Driven programming is the technique of factoring repetitious programming constructs into data and a transformation pattern. This new data is often referred to by purists as meta-data when used in this fashion.

Robert Harvey
  • 168,684
  • 43
  • 314
  • 475
1

There is no one at work that can help you with this question? It is very hard to visualize what you are working without without a greater example. But from what I gather it is going to be a program that they primarily enter information into. That will be able to retrieve and edit information that the customer needs to manage.

Best of luck!!

Chris Bier
  • 12,978
  • 15
  • 60
  • 100
1

I think the advice given isn't bad, but I've always thought of Data Driven Design revolves around using existing or given data structures as the foundation for your domain objects.

For instance, the classic salesperson management program might have the following type structure of tables:

  • Salesperson
  • Region
  • Customers
  • Products

So, your application would be centered around managing these data structures, instead of taking a straight API which does things like - "make sale" etc...

Just my opinion as the other answers suggest ;)

Jens
  • 61,963
  • 14
  • 104
  • 160
cgp
  • 39,478
  • 10
  • 96
  • 129