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

前端 未结 2 1292
一向
一向 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).

提交回复
热议问题