A dynamic model is an object-oriented programming method that uses tree-structured data (such as XML, JSON, etc.) to program.
For example, the following XML is a model program, the XML itself is called a model, and each node of it is an object. You can click here to run the model, which will open a window with a browser showing the XWorker home page.
<?xml version="1.0" encoding="utf-8"?>
<Shell name="shell" text="Hello World!" descriptors="xworker.swt.widgets.Shell"
<Browser name="Browser" url="https://www.xworker.org"></Browser>
2. Basic Concepts
The basic concepts of the dynamic model are abstract, but object-oriented and other programming methods can be implemented based on these concepts.
- Models and Things
Dynamic models refer to a tree-structured data as a model, and believe that anything can be represented using a model (such as XML or JSON), so a model is sometimes called a thing.
In addition, each node in a tree-structured data in a dynamic model is treated as an independent model.
The dynamic model believes that any model can be transformed into actions to execute, where actions are equivalent to functions and methods.
The action context is the execution environment of the action, which is used to manage variables and maintain the execution state of the action. Action contexts are also sometimes called variable contexts.
The world is the manager of the model, since the model is sometimes called a thing, and the collection of various things can be called the world.
The Model Manager is equivalent to a model project or library and is used to manage models. For example, models can be stored in Java libraries, or in databases or Redis. A Jar or a database corresponds to a model manager.
Equivalent to a Java package for grouping models.
Object-oriented is a major programming method in dynamic model programming, which is based on the above concepts.
Models can be used to represent objects. A model is tree-structured data, and tree-structured data (such as XML) itself contains attributes and sub-nodes, which can be used to represent the attributes and sub-objects of objects. In addition, the dynamic model believes that any model can be transformed into an action to execute, so some child nodes of a model can be regarded as its behavior.
- Classes and Descriptors
The dynamic model considers classes as relationships between objects, so any object (including the object itself) can act as a class of objects. Among them, the class has the ability to describe the structure and behavior of the object, so the class is also called the descriptor in the dynamic model.
In the dynamic model, if model B is the class of model A, then B is called the class or descriptor of A, and A inherits the behavior of B.
In a dynamic model, a model can inherit from any other model, thereby inheriting the behavior of the inherited model.
If a model is used as a describer, it also inherits the description capabilities. For example, humans inherit the attributes and behaviors of animals.
4. Implementation principle
To be able to use a dynamic model for programming, it needs to be able to actually execute as a program. It needs to realize the assumption that any model can be transformed into an action to execute. The principle of implementation is as follows.
- It is assumed that any model can be transformed into an action, and when the model is transformed into an action execution, the actual execution is the behavior named run of the model (object).
- The behavior of a model (object) is also a model (object), so the behavior of a model (object) named run is also a model (object). To execute the behavior named run, go back to step 1.
- The above is an iterative process. If the iteration can be terminated, there should be a meta-system to explain the execution when some models (objects) are executed.
The meta system refers to the system that implements the dynamic model. For example, the dynamic model engine used by XWorker is written in Java, and Java is its meta system.