Introduction to Dynamic Models

1. Introduction

    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, and each node of this XML 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"
  width="800" height="600">
    <FillLayout name="FillLayout"></FillLayout>
    <Browser name="Browser" url="https://www.xworker.org"></Browser>
</Shell>

2. Features

  • Structured programming approach: Dynamic models are programmed using tree-structured data, such as XML or JSON. Below we use XML as an example.
  • Object-Oriented Programming: The dynamic model is an object-oriented programming method.
  • Objects and Models: When programming in XML, any XML and any node in XML are treated as independent objects. The XML used to represent objects is generally called a model.
  • Action: Any object can be transformed into an action. Actions are equivalent to methods and functions and can be executed.
  • Behavior: Some child nodes of an object can be artificially specified as its behavior.
  • Class: You can take other objects or objects themselves as the class of the object, and the object inherits the behavior of the class. An object can have any class.
  • Inheritance: An object can inherit from any other object, thereby inheriting their behavior. An object can inherit from any number of other objects.
  • Interpretation and execution: Execution program is to execute the behavior of the object, and the behavior of the object is interpreted and executed in real time.
  • Dynamic: An object's class, inheritance, properties, and behavior can be modified at any time at runtime.

3. Implementation principle

    The dynamic model itself is an abstract programming method, and other programming languages are required to implement the dynamic model engine.

    To implement dynamic model programming, it is necessary to implement a method in which objects are converted into actions and can be executed. The principle of implementation is as follows.

  1. Any object can be transformed into an action. When an action is executed, the behavior of the model object named run is executed.
  2. The behavior of an object is also an object, so the behavior of an object named run is also an object. To execute the behavior named run, go back to step 1.
  3. The above is an iterative process. If the iteration can be terminated, there should be a meta-system to explain the execution when some 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.

Copyright ©  2007-2019 XWorker.org  版权所有  沪ICP备08000575号