为智能系统做准备

    模型是数据,可以被程序修改,并且模型的修改也可以实时生效。模型的数据特征为将来通过程序来管理程序提供了一个便利的条件,希望将来能够实现自动化编程和智能化编程。

    目前智能化编程还未实现,但下面的示意代码说明了模型的类、继承、属性和行为等都可以随时被修改。

Thing thing = new Thing();

//设置描述者(类)
thing.set("descriptors", "Person");

//设置继承
thing.set("extends", "Animal");

//设置属性
thing.set("name", "zhangsan");

//添加行为主节点
Thing actions = new Thing("actions");
actions.set("name", "actions");
thing.addChild(actions);

//添加一个run行为
Thing run = new Thing("xworker.lang.actions.GroovyAction");
run.set("name", run);
run.set("code", "println \"hello world\"");

//执行run行为
thing.doAction("run", new ActionContext());