What is the difference between data-centric and object-oriented application models?

前端 未结 2 1293
一向
一向 2021-02-13 23:37

What is a data-centric application and is there any difference with an object-oriented application model ?

相关标签:
2条回答
  • 2021-02-14 00:35

    A data centric design is one where the application behavior is encapsulated by data. A simple example. Consider the following OOP class:

    class Car {
        void move(x, y);
    private:
        int x, y;
    }
    

    This is an OOP representation of a car. Invoking the 'move' method will trigger the car to start moving. In other words, any side effects are triggered by invoking the class methods.

    Here's the same class, but data centric:

    class Car {
       int x, y;
    }
    

    In order to get this car moving, I would "simply" change the values of x and y. In most programming languages changing members won't allow for the execution of logic, which is why data centricity often requires a framework.

    In such a framework, logic is ran upon the C, U and D of CRUD. Such a framework will provide the appropriate facilities to enable code insertion at any of these events, for example:

    • DBMS triggers
    • OMG DDS waitsets/listeners (DDS is a data centric messaging standard)
    • corto observers (corto is a data centric application framework)

    Data centric design has many implications. For example, since an application state is effectively represented by its data, you can automatically persist the application. A well-written data centric application can be stored, stopped and restored from a database, and continue like it was never gone.

    Data centric designs are a good match for traditional 3 tier web architectures. Web applications are typically driven by the contents of the backend database. That is why, when you close and reopen a dynamic webpage, it still looks the same (provided the data didn't change).

    0 讨论(0)
  • 2021-02-14 00:36

    The two concepts are somewhat orthogonal, a Data Centric Application is one where the database plays a key role, where properties in the database may influence the code paths running in your application and where the code is more generic and all/most business logic is defined through database relations and constraints. OOP can be used to create a data centric application.

    Some of the large multi-tier architectures which people think of when they say OOP architecture implement business logic in code and just store the data in the database. However, it would be wrong to think Object Oriented design necessarily has to be a large business logic ridden system.

    Say you have to implement message passing between two systems. One way (although a bad way) is to have each of the systems write the messages to the database and the other system read from the database every so often to pick up messages. This would be a data centric approach as there is very little code needed other than reading and writing data.

    The same system could be implemented by having the systems open a socket connection to each other and send messages directly. In this way there is more code and less database access. This is the non-datacentric approach. Either of these could be implemented using OOP concepts.

    Another example from my work we implement servers for games, one type of server handles multi-player game play so user presses the button and spaceship fires missile at other player. This server is not datacentric it is event based. Another server stores the users high scores, friend lists etc this server is thin wrapper over the database which stores the score and lists.

    0 讨论(0)
提交回复
热议问题