第五章 Class/Object/Method工程模型
5.1 Class/Object/Method工程模型的提出
在结构智能理论中,Class、Object、Attribute、Value 和 Method 不是孤立的程序设计概念,而是构成结构智能对象系统的重要结构。
前面的 Element 工程模型解决了:
ElementElement
如何作为基本结构单位进入系统。
Structure 工程模型解决了:
Element+Relation→StructureElement+Relation \rightarrow Structure
Knowledge 工程模型解决了:
Structure→KnowledgeStructure \rightarrow Knowledge
而 Class/Object/Method 工程模型进一步解决:
结构中的对象如何形成,对象具有什么属性,属性具有什么值,以及对象如何通过方法进行运算和行为处理。
因此形成:
Element→Class→Object→Attribute→ValueElement \rightarrow Class \rightarrow Object \rightarrow Attribute \rightarrow Value
以及:
Object→Method→MethodInstance→Operation→ResultObject \rightarrow Method \rightarrow MethodInstance \rightarrow Operation \rightarrow Result
这两条结构与运行路径共同构成对象级结构智能的工程基础。
完整表示为:
Class={Attribute,Method}Class= \{Attribute,Method\} Class→ObjectClass\rightarrow Object Object→Attribute→ValueObject\rightarrow Attribute\rightarrow Value Object→MethodObject\rightarrow Method Method→MethodInstanceMethod\rightarrow MethodInstance MethodInstance→ParameterBinding→Operation→ResultMethodInstance \rightarrow ParameterBinding \rightarrow Operation \rightarrow Result
这里必须明确:
Class≠ObjectClass\neq Object Object≠AttributeObject\neq Attribute Attribute≠ValueAttribute\neq Value Method≠OperationMethod\neq Operation Method≠CapabilityMethod\neq Capability
这些边界是工程实现保持理论一致性的基础。
5.2 Class的工程定义
5.2.1 Class的理论含义
Class 是对象结构的抽象定义。
它规定某一类对象具有什么结构属性,以及这些对象可以调用什么方法。
因此:
Class={AttributeDefinition,MethodDefinition,RelationDefinition,RuleDefinition}Class= \{ AttributeDefinition, MethodDefinition, RelationDefinition, RuleDefinition \}
最基本形式为:
Class={Attribute,Method}Class= \{ Attribute, Method \}
例如定义一个产品类:
ProductClass={Brand,Price,Certification,Function,Manufacturer,TargetUser,Method1,Method2,…}ProductClass= \{ Brand, Price, Certification, Function, Manufacturer, TargetUser, Method_1, Method_2,\ldots \}
此时 ProductClass 并不是一个具体产品。
它只是规定:
什么样的结构可以被作为 Product 对象,以及 Product 对象可以具有哪些属性和方法。
5.3 Class的工程表示
系统中需要给 Class 建立独立身份。
可以表示为:
Class={ID,Name,Definition,Attributes,Methods,Relations,Rules,Status,Version}Class= \{ ID, Name, Definition, Attributes, Methods, Relations, Rules, Status, Version \}
其中:
ID:Class唯一标识;Name:Class名称;Definition:Class结构定义;Attributes:属性定义;Methods:方法定义;Relations:关系定义;Rules:结构规则;Status:Class状态;Version:Class版本。
其中最核心的是:
ClassIDClassID
因为系统不能仅通过名称判断 Class 的身份。
例如:
ProductClass1ProductClass_1
和:
ProductClass2ProductClass_2
即使名称相同,只要结构定义不同,就可以是不同 Class。
因此:
SameName≠SameClassSameName\neq SameClass
5.4 Class与Structure的关系
Class来源于 Structure,但 Class 不等于 Structure。
Structure 是更一般的结构概念:
Structure={Element,Relation}Structure=\{Element,Relation\}
Class 是一种具有对象实例能力的结构定义。
因此可以表示:
Structure→ClassDefinitionStructure \rightarrow ClassDefinition
而:
Class={AttributeDefinition,MethodDefinition,RelationDefinition}Class= \{ AttributeDefinition, MethodDefinition, RelationDefinition \}
例如一个结构定义确定:
ProductProduct
具有:
Brand, Price, FunctionBrand,\ Price,\ Function
那么工程系统可以进一步形成:
ProductClassProductClass
并由此创建:
ProductObjectProductObject
因此:
Structure→Class→ObjectStructure\rightarrow Class\rightarrow Object
但不能反过来说:
Structure=ClassStructure=Class
5.5 Attribute工程模型
5.5.1 Attribute的定义
Attribute 是 Object 的结构性特征。
基本关系:
Object→AttributeObject\rightarrow Attribute
例如:
Product→PriceProduct \rightarrow Price Product→BrandProduct \rightarrow Brand Product→FunctionProduct \rightarrow Function
Attribute本身描述“具有哪一种特征”,而不是具体的特征值。
因此:
PricePrice
是 Attribute。
而:
29.9929.99
是 Value。
所以:
Attribute≠ValueAttribute\neq Value
5.5.2 Attribute工程表示
Attribute可以定义为:
AttributeDefinition={ID,Name,Type,Required,Default,Rule,Status}AttributeDefinition= \{ ID, Name, Type, Required, Default, Rule, Status \}
其中:
ID:属性标识;Name:属性名称;Type:属性数据类型或结构类型;Required:是否要求存在;Default:默认值;Rule:属性约束;Status:属性状态。
这里的 Type 必须区别于自然语言中的类型判断。
例如:
PricePrice
的数据类型可能是数值,但它的结构语义是:
Product.PriceProduct.Price
因此:
DataType≠StructuralMeaningDataType\neq StructuralMeaning
5.6 Value工程模型
5.6.1 Value的定义
Value 是 Attribute 在具体 Object 上的实际值。
基本关系:
Object→Attribute→ValueObject\rightarrow Attribute\rightarrow Value
例如:
Product.Price=29.99Product.Price=29.99
其中:
ProductProduct
是 Object;
PricePrice
是 Attribute;
29.9929.99
是 Value。
Value 可以是:
- 数值;
- 文本;
- 日期;
- 布尔值;
- Element;
- Object引用;
- 集合;
- 结构;
- 状态;
- 关系结果;
- 运算结果。
因此 Value 不应被简单限制为字符串。
5.7 Value的工程表示
可以表示为:
Value={ID,Data,Type,Source,Context,Status}Value= \{ ID, Data, Type, Source, Context, Status \}
其中:
Data 是实际数据;
Type 是数据类型;
Source 保存来源;
Context 保存该值所处的对象、属性、场景、时间和条件;
Status 表示该值是否有效。
因此:
Value=Data+ContextValue=Data+Context
比单纯:
Value=DataValue=Data
具有更强的结构意义。
例如:
29.9929.99
本身没有完整语义。
而:
Product.Price=29.99Product.Price=29.99
已经具有对象、属性和值三层结构。
如果再加入市场和时间:
Product.Price(USA,2026)=29.99Product.Price(USA,2026)=29.99
则形成更加完整的条件化知识。
5.8 Object工程模型
5.8.1 Object的定义
Object 是 Class 的具体实例。
基本关系:
Class→ObjectClass\rightarrow Object
例如:
ProductClass→ProductObjectProductClass \rightarrow ProductObject
如果:
ProductClassProductClass
定义:
Brand, Price, FunctionBrand,\ Price,\ Function
那么一个具体产品可以成为:
ProductObject001ProductObject_001
并具有:
Brand=ABrand=A Price=29.99Price=29.99 Function=ChargingFunction=Charging
因此:
Object=ClassInstance+AttributeValuesObject= ClassInstance+AttributeValues
5.9 Object的工程表示
系统中的 Object 可以表示为:
Object={ID,ClassID,Attributes,Relations,State,Context,Status,Version}Object= \{ ID, ClassID, Attributes, Relations, State, Context, Status, Version \}
其中:
ID:对象唯一标识;ClassID:对象所属 Class;Attributes:对象属性及值;Relations:对象关系;State:对象状态;Context:对象所在场景和条件;Status:对象当前状态;Version:对象版本。
最关键的关系是:
Object.ClassID=Class.IDObject.ClassID=Class.ID
因此对象必须能够追溯其 Class 定义。
5.10 Object身份
Object不能仅通过名称确定。
例如:
电动牙刷
可能表示:
- 一个产品类别;
- 一个具体产品;
- 一个产品对象集合;
- 一条知识中的对象。
因此:
ObjectIDObjectID
必须作为对象工程身份。
即:
SameName≠SameObjectSameName\neq SameObject
例如:
ProductObject001ProductObject_001
和:
ProductObject002ProductObject_002
都可以属于:
ProductClassProductClass
但它们是两个不同对象。
因此:
ClassID≠ObjectIDClassID\neq ObjectID
5.11 Object与Attribute的实例化
Class定义属性:
Class→AttributeDefinitionClass\rightarrow AttributeDefinition
Object实例化以后拥有具体属性:
Object→AttributeObject\rightarrow Attribute
然后属性绑定具体值:
Attribute→ValueAttribute\rightarrow Value
完整过程:
Class→AttributeDefinition→Object→AttributeInstance→ValueClass \rightarrow AttributeDefinition \rightarrow Object \rightarrow AttributeInstance \rightarrow Value
例如:
ProductClass.PriceProductClass.Price
是属性定义。
实例化以后:
ProductObject001.Price=29.99ProductObject_001.Price=29.99
形成具体属性值。
因此:
AttributeDefinition≠AttributeInstanceAttributeDefinition\neq AttributeInstance
5.12 Object状态工程模型
Object不仅具有静态属性,还可以具有动态状态。
基本形式:
State=f(Object,Attribute,Value,Relation,Condition,Environment)State=f(Object,Attribute,Value,Relation,Condition,Environment)
例如:
Battery.Level=20%Battery.Level=20\%
结合规则:
Level<30%→State=LowBatteryLevel<30\% \rightarrow State=LowBattery
因此:
Value→StateValue\rightarrow State
状态也可以随着执行发生变化:
Valueold→Execution→ValuenewValue_{old} \rightarrow Execution \rightarrow Value_{new}
从而:
Stateold→StatenewState_{old} \rightarrow State_{new}
所以 Object 工程模型必须允许状态变化。
5.13 Object与Relation
Object不是孤立存在的。
对象之间可以建立 Relation:
Object1↔Relation↔Object2Object_1 \leftrightarrow Relation \leftrightarrow Object_2
例如:
Product→manufacturedBy→ManufacturerProduct \rightarrow manufacturedBy \rightarrow Manufacturer
或者:
Product→belongsTo→CategoryProduct \rightarrow belongsTo \rightarrow Category
关系本身也是结构。
因此:
Object+Relation+Object→ObjectStructureObject+Relation+Object \rightarrow ObjectStructure
多个对象和关系进一步形成:
StructureStructure
以及:
KnowledgeStructureKnowledgeStructure
5.14 Method工程模型
5.14.1 Method的定义
Method 是与对象结构相关的可执行方法定义。
它规定:
在什么目标、对象、输入、条件和参数下,通过什么运算产生什么结果。
基本结构:
Method={Goal,Input,Object,Condition,Parameter,Rule,Operation,Output,Validation}Method= \{ Goal, Input, Object, Condition, Parameter, Rule, Operation, Output, Validation \}
对于 Class 中的方法,可以进一步表示:
ClassMethod={Name,Input,Parameter,Condition,Operation,Output,Validation}ClassMethod= \{ Name, Input, Parameter, Condition, Operation, Output, Validation \}
因此:
Class={Attribute,Method}Class=\{Attribute,Method\}
5.15 Method与Object的关系
Class中的 Method 属于 Class 定义的一部分。
当 Class 被实例化为 Object 后,Method 可以作用于该 Object。
因此:
Class→MethodDefinitionClass \rightarrow MethodDefinition
以及:
Class→ObjectClass \rightarrow Object
最终:
Object→ClassMethodObject \rightarrow ClassMethod
例如:
ProductClassProductClass
定义:
comparePrice()comparePrice()
实例化:
ProductObject001ProductObject_001
以后可以调用:
ProductObject001.comparePrice(30)ProductObject_001.comparePrice(30)
这里的:
comparePricecomparePrice
不是单纯函数名称,而是:
MethodDefinitionMethodDefinition
经过对象绑定和参数绑定以后形成:
MethodInstanceMethodInstance
5.16 Method实例化
方法定义不能直接等同于一次实际执行。
因此:
Method→MethodInstanceMethod\rightarrow MethodInstance
Method实例化至少包括:
MethodInstance={MethodID,Object,Parameter,Condition,Context,Input}MethodInstance= \{ MethodID, Object, Parameter, Condition, Context, Input \}
例如方法定义:
comparePrice(TargetPrice)comparePrice(TargetPrice)
具体调用:
ProductObject.Price=29.99ProductObject.Price=29.99
参数:
TargetPrice=30TargetPrice=30
形成:
MethodInstance={ProductObject001,Price=29.99,TargetPrice=30}MethodInstance= \{ ProductObject_001, Price=29.99, TargetPrice=30 \}
然后执行:
compare(29.99,30)compare(29.99,30)
得到:
Result=TrueResult=True
因此:
Method≠MethodInstanceMethod \neq MethodInstance MethodInstance≠OperationMethodInstance \neq Operation
5.17 Parameter工程模型
方法执行必须能够接收参数。
因此:
Method→ParameterDefinitionMethod \rightarrow ParameterDefinition
实例化以后:
ParameterDefinition→ParameterValueParameterDefinition \rightarrow ParameterValue
例如:
compare(Value1,Value2)compare(Value_1,Value_2)
实际调用:
compare(29.99,30)compare(29.99,30)
形成:
ParameterBinding={Value1→29.99,Value2→30}ParameterBinding= \{ Value_1\rightarrow29.99, Value_2\rightarrow30 \}
参数可以来自:
- Object属性;
- Value;
- Knowledge;
- Requirement;
- CognitionResult;
- Decision;
- 其他MethodResult;
- 外部输入。
因此:
ParameterParameter
也是结构智能中的重要连接结构。
5.18 Method与Attribute Value的运算
结构智能中的方法可以直接作用于对象属性值。
基本路径:
Object→Attribute→Value→Method→Operation→ResultObject \rightarrow Attribute \rightarrow Value \rightarrow Method \rightarrow Operation \rightarrow Result
例如:
Product.Price=29.99Product.Price=29.99
调用:
compare(Product.Price,30)compare(Product.Price,30)
形成:
29.99<3029.99<30
结果:
TrueTrue
进一步:
True→Judge→LowPriceTrue \rightarrow Judge \rightarrow LowPrice
因此方法可以通过对象属性值完成结构运算。
5.19 Method与Relation的运算
方法不仅可以处理 Value,也可以处理 Relation。
例如:
Product→manufacturedBy→CompanyAProduct \rightarrow manufacturedBy \rightarrow CompanyA
可以通过:
verifyRelation(Product,manufacturedBy,CompanyA)verifyRelation(Product,manufacturedBy,CompanyA)
验证关系。
也可以:
matchRelation(Product,Manufacturer)matchRelation(Product,Manufacturer)
寻找符合条件的厂家关系。
因此:
MethodMethod
可以作用于:
ValueValue
也可以作用于:
AttributeAttribute ObjectObject RelationRelation StructureStructure
以及:
KnowledgeKnowledge
5.20 Method与Rule
Method可以调用 Rule。
例如:
Price<30Price<30
是一条判断规则。
方法:
judgePrice(Product.Price)judgePrice(Product.Price)
调用:
Rule(Price<30)Rule(Price<30)
形成:
Result=TrueResult=True
因此:
Method→Rule→OperationMethod \rightarrow Rule \rightarrow Operation
也可以:
Method→Rule→Judge→ResultMethod \rightarrow Rule \rightarrow Judge \rightarrow Result
Rule规定条件关系,Method规定如何使用这些规则。
因此:
Rule≠MethodRule\neq Method
5.21 Method与Operation的边界
必须严格区分:
Method≠OperationMethod\neq Operation
Method是执行结构。
Operation是实际发生的处理过程。
例如:
Method=ComparePriceMethod=ComparePrice
规定:
将产品价格与目标价格进行比较。
实际:
Operation=compare(29.99,30)Operation=compare(29.99,30)
产生:
Result=TrueResult=True
因此:
Method→MethodInstance→Operation→ResultMethod \rightarrow MethodInstance \rightarrow Operation \rightarrow Result
Method可以包含多个 Operation:
Method=Operation1+Operation2+⋯+OperationnMethod = Operation_1 + Operation_2 + \cdots + Operation_n
例如一个产品筛选方法:
Method=SelectProductMethod=SelectProduct
内部可以执行:
Filter→Compare→Sort→VerifyFilter \rightarrow Compare \rightarrow Sort \rightarrow Verify
最终形成结果。
5.22 Method与Capability的边界
Method也不能等同于 Capability。
Method≠CapabilityMethod\neq Capability
Capability表示:
能够完成什么任务。
Method表示:
通过什么结构路径完成任务。
例如:
Capability=ProductSelectionCapabilityCapability=ProductSelectionCapability
表示系统能够完成产品选择任务。
其中可能调用:
Method1=FilterProductMethod_1=FilterProduct Method2=ComparePriceMethod_2=ComparePrice Method3=VerifyCertificationMethod_3=VerifyCertification
因此:
Capability→Method→OperationCapability \rightarrow Method \rightarrow Operation
Capability可以调用一个方法,也可以组合多个方法。
5.23 Class Method与Problem-Solving Method
Class中的 Method 主要作用于具体对象和对象结构。
但是完整问题解决通常需要多个对象、多个能力和多个方法协同。
因此需要区分:
ClassMethodClassMethod
和:
ProblemSolvingMethodProblemSolvingMethod
ClassMethod:
Object→ClassMethod→OperationObject \rightarrow ClassMethod \rightarrow Operation
ProblemSolvingMethod:
Requirement→Knowledge→Capability→Decision→Method→ExecutionRequirement \rightarrow Knowledge \rightarrow Capability \rightarrow Decision \rightarrow Method \rightarrow Execution
因此:
ClassMethod⊂MethodClassMethod\subset Method
而完整的问题解决方法可以组织多个 ClassMethod:
ProblemSolvingMethod→ClassMethod1+ClassMethod2+⋯+ClassMethodnProblemSolvingMethod \rightarrow ClassMethod_1 + ClassMethod_2 + \cdots + ClassMethod_n
这使 Class/Object/Method 模型能够进入完整的结构智能执行体系。
5.24 Method组合
一个方法可以调用另一个方法。
因此:
Method1→Method2→Method3Method_1 \rightarrow Method_2 \rightarrow Method_3
可以形成:
CompositeMethodCompositeMethod
例如:
SelectProductSelectProduct
可以由:
MatchProductMatchProduct FilterPriceFilterPrice VerifyCertificationVerifyCertification SortProductSortProduct
组合形成。
即:
CompositeMethod=Method1+Method2+Method3+Method4CompositeMethod= Method_1+Method_2+Method_3+Method_4
因此方法具有层级性。
可以形成:
ClassMethod→CapabilityMethod→ProblemSolvingMethod→CompositeMethodClassMethod \rightarrow CapabilityMethod \rightarrow ProblemSolvingMethod \rightarrow CompositeMethod
5.25 Class/Object/Method的完整实例化过程
完整的对象工程过程可以表示为:
ClassDefinition→ObjectInstantiation→AttributeBinding→ValueBindingClassDefinition \rightarrow ObjectInstantiation \rightarrow AttributeBinding \rightarrow ValueBinding
同时:
ClassMethodDefinition→MethodInstantiation→ParameterBinding→Operation→ResultClassMethodDefinition \rightarrow MethodInstantiation \rightarrow ParameterBinding \rightarrow Operation \rightarrow Result
合并以后:
Class→Object→Attribute→ValueClass \rightarrow Object \rightarrow Attribute \rightarrow Value
以及:
Object→Method→MethodInstance→Operation→ResultObject \rightarrow Method \rightarrow MethodInstance \rightarrow Operation \rightarrow Result
形成完整对象执行结构。
5.26 Class/Object/Method与Knowledge
Knowledge 可以描述 Class、Object、Attribute、Value 和 Method 之间的关系。
例如:
Knowledge={Product,Price=29.99,Function=Charging}Knowledge= \{ Product, Price=29.99, Function=Charging \}
可以进一步形成:
ProductClassProductClass
以及:
ProductObjectProductObject
因此:
Knowledge→ObjectStructureKnowledge \rightarrow ObjectStructure
同时对象的实际属性值又可以成为 Knowledge 的组成部分:
Object→Attribute→Value→KnowledgeObject \rightarrow Attribute \rightarrow Value \rightarrow Knowledge
所以 Knowledge 与 Object 模型之间是双向关联关系:
Knowledge↔ObjectStructureKnowledge \leftrightarrow ObjectStructure
但:
Knowledge≠ObjectKnowledge\neq Object
知识是关于对象及其关系、属性、状态、条件等的结构化内容。
5.27 Class/Object/Method与可运算知识
当 Knowledge 与 Class/Object/Method 结合以后,就形成更明确的可运算结构:
Knowledge→Object→Attribute→Value→Method→Operation→ResultKnowledge \rightarrow Object \rightarrow Attribute \rightarrow Value \rightarrow Method \rightarrow Operation \rightarrow Result
例如:
Knowledge:Product.Price=29.99Knowledge: Product.Price=29.99
对象实例:
ProductObject.Price=29.99ProductObject.Price=29.99
方法:
ComparePriceComparePrice
参数:
3030
运算:
compare(29.99,30)compare(29.99,30)
结果:
TrueTrue
因此:
Knowledge+Object+Method→ComputableStructureKnowledge+Object+Method \rightarrow ComputableStructure
这就是结构智能从“知道”进入“运算”的重要工程基础。
5.28 Class/Object/Method与认知
认知过程同样可以利用 Class/Object 模型。
原始信息:
电动牙刷售价29.99美元。
首先形成 Element:
Element(电动牙刷)Element(电动牙刷) Element(29.99)Element(29.99)
通过知识和结构匹配:
29.99→Price29.99 \rightarrow Price
并与:
ElectricToothbrushElectricToothbrush
对象绑定:
ElectricToothbrush.Price=29.99ElectricToothbrush.Price=29.99
此时:
CognitionResult={Object=ElectricToothbrush,Attribute=Price,Value=29.99}CognitionResult= \{ Object=ElectricToothbrush, Attribute=Price, Value=29.99 \}
如果进一步根据:
Price<30Price<30
判断状态:
State=LowPriceState=LowPrice
则形成:
CognitionResult={Object,Price=29.99,State=LowPrice}CognitionResult= \{ Object, Price=29.99, State=LowPrice \}
因此 Class/Object/Attribute/Value 是认知结果结构化的重要工程基础。
5.29 Class/Object/Method与决策
决策可以直接调用对象属性和方法。
例如采购需求:
Price<30Price<30
系统首先获得多个 Object:
ProductObject1ProductObject_1 ProductObject2ProductObject_2 ProductObject3ProductObject_3
然后调用:
comparePrice()comparePrice()
得到:
Result1Result_1 Result2Result_2 Result3Result_3
进一步:
Filter→Compare→Sort→VerifyFilter \rightarrow Compare \rightarrow Sort \rightarrow Verify
形成候选结果。
最终:
DecisionDecision
选择满足目标、条件和约束的对象。
因此:
Object→Method→Operation→Result→DecisionObject \rightarrow Method \rightarrow Operation \rightarrow Result \rightarrow Decision
5.30 Object状态与执行
对象的属性值可以在执行过程中发生变化。
例如:
Device.Battery=100%Device.Battery=100\%
执行充电消耗或设备运行:
ExecutionExecution
以后:
Device.Battery=80%Device.Battery=80\%
因此:
Batteryold=100%Battery_{old}=100\% Batterynew=80%Battery_{new}=80\%
形成:
ObjectStateold→Execution→ObjectStatenewObjectState_{old} \rightarrow Execution \rightarrow ObjectState_{new}
对象状态变化进一步形成:
Result→FeedbackResult \rightarrow Feedback
因此 Object 工程模型不是静态数据模型,而是可以参与动态世界变化的结构模型。
5.31 Class/Object/Method的工程生命周期
Class的生命周期:
ClassDefinition→Create→Activate→Use→Update→Version→DeprecateClassDefinition \rightarrow Create \rightarrow Activate \rightarrow Use \rightarrow Update \rightarrow Version \rightarrow Deprecate
Object的生命周期:
ObjectInstantiation→Bind→Use→StateChange→Update→ArchiveObjectInstantiation \rightarrow Bind \rightarrow Use \rightarrow StateChange \rightarrow Update \rightarrow Archive
Method的生命周期:
MethodDefinition→Instantiate→Bind→Execute→Validate→UpdateMethodDefinition \rightarrow Instantiate \rightarrow Bind \rightarrow Execute \rightarrow Validate \rightarrow Update
三者最终形成:
Class→Object→Method→Execution→Result→FeedbackClass \rightarrow Object \rightarrow Method \rightarrow Execution \rightarrow Result \rightarrow Feedback
5.32 Class/Object/Method的更新
Class发生变化时,对象结构可能需要重新验证。
例如 Class 原来定义:
Product={Brand,Price,Function}Product= \{ Brand, Price, Function \}
后来增加:
CertificationCertification
形成:
Class(1)→Class(2)Class^{(1)} \rightarrow Class^{(2)}
那么已有 Object 需要进行结构验证:
Object→ClassValidationObject \rightarrow ClassValidation
判断:
Object⊆Class(2)Object\subseteq Class^{(2)}
如果新属性是必要属性,则可能形成:
AttributeGapAttributeGap
进一步进入学习:
AttributeGap→KnowledgeRequirement→InformationRequirementAttributeGap \rightarrow KnowledgeRequirement \rightarrow InformationRequirement
因此 Class 更新可能影响:
Object→Knowledge→Capability→MethodObject \rightarrow Knowledge \rightarrow Capability \rightarrow Method
5.33 Method更新
Method也会因为执行反馈发生变化。
原方法:
Method(1)Method^{(1)}
执行:
ExecutionExecution
产生:
FailureFailure
反馈:
FeedbackFeedback
经过分析发现方法步骤存在问题:
MethodGapMethodGap
于是:
Method(1)→Method(2)Method^{(1)} \rightarrow Method^{(2)}
并重新验证:
Method(2)→Execution→Result→ValidationMethod^{(2)} \rightarrow Execution \rightarrow Result \rightarrow Validation
只有验证有效以后,新的方法才成为可用方法。
因此:
Feedback→MethodUpdateFeedback\rightarrow MethodUpdate
是结构智能学习和演化的重要路径。
5.34 Class/Object/Method与系统工程存储
在实际系统中,Class、Object、Attribute、Value 和 Method 可以分别保存,也可以根据系统架构进行组合存储。
例如:
ClassDefinitionClassDefinition
保存 Class 定义;
ObjectDataObjectData
保存 Object 实例;
AttributeDataAttributeData
保存属性和值;
MethodDefinitionMethodDefinition
保存方法定义;
MethodInstanceMethodInstance
保存一次具体方法调用;
ExecutionRecordExecutionRecord
保存实际执行过程。
但是无论采用数据库还是 JSON,必须保持理论关系:
ClassID→Object.ClassIDClassID \rightarrow Object.ClassID ObjectID→AttributeObjectID \rightarrow Attribute AttributeID→ValueAttributeID \rightarrow Value MethodID→MethodInstanceMethodID \rightarrow MethodInstance MethodInstance→ObjectIDMethodInstance \rightarrow ObjectID MethodInstance→ParameterMethodInstance \rightarrow Parameter
因此工程存储只是理论结构的载体。
5.35 Class/Object/Method与Element的关系
Element是最基础结构单位。
Class、Object、Attribute、Value 和 Method 都可以由 Element 构成。
例如:
Element1=ProductElement_1=Product Element2=PriceElement_2=Price Element3=29.99Element_3=29.99
通过结构关系:
Element1→Element2→Element3Element_1 \rightarrow Element_2 \rightarrow Element_3
形成:
Object→Attribute→ValueObject\rightarrow Attribute\rightarrow Value
同样:
Element4=CompareElement_4=Compare
可以形成:
Object→MethodObject \rightarrow Method
因此:
Element→Structure→Class/Object/MethodElement \rightarrow Structure \rightarrow Class/Object/Method
这说明 Element 是底层结构单位,而 Class/Object/Method 是更高层的结构组织形式。
5.36 Class/Object/Method与Structure的统一关系
综合前面的结构模型:
Element→StructureElement\rightarrow Structure
Class进一步定义对象结构:
Structure→ClassStructure\rightarrow Class
Class实例化:
Class→ObjectClass\rightarrow Object
对象形成属性:
Object→Attribute→ValueObject\rightarrow Attribute\rightarrow Value
对象调用方法:
Object→MethodObject\rightarrow Method
方法实例化:
Method→MethodInstanceMethod\rightarrow MethodInstance
实际运算:
MethodInstance→OperationMethodInstance\rightarrow Operation
最终:
Operation→ResultOperation\rightarrow Result
因此形成:
Element→Structure→Class→Object→Attribute→Value\boxed{ Element \rightarrow Structure \rightarrow Class \rightarrow Object \rightarrow Attribute \rightarrow Value }
以及:
Object→Method→MethodInstance→Operation→Result\boxed{ Object \rightarrow Method \rightarrow MethodInstance \rightarrow Operation \rightarrow Result }
两条路径最终汇合于:
Result→Feedback→LearningResult \rightarrow Feedback \rightarrow Learning
5.37 Class/Object/Method工程模型的统一对象模型
可以将整个对象工程模型统一表示为:
Class={AttributeDefinition,MethodDefinition,RelationDefinition,RuleDefinition}\boxed{ Class= \{AttributeDefinition,MethodDefinition,RelationDefinition,RuleDefinition\} } Object={ClassID,Attribute,Value,Relation,State,Context}\boxed{ Object= \{ClassID,Attribute,Value,Relation,State,Context\} } Method={Goal,Input,Object,Parameter,Condition,Rule,Operation,Output,Validation}\boxed{ Method= \{Goal,Input,Object,Parameter,Condition,Rule,Operation,Output,Validation\} }
运行时:
Method→MethodInstance→ObjectBinding→ParameterBinding→Operation→Result\boxed{ Method \rightarrow MethodInstance \rightarrow ObjectBinding \rightarrow ParameterBinding \rightarrow Operation \rightarrow Result }
因此:
ClassClass
解决“对象属于什么结构”。
ObjectObject
解决“当前具体对象是什么”。
AttributeAttribute
解决“对象具有什么特征”。
ValueValue
解决“该特征当前具有什么值”。
MethodMethod
解决“如何对对象及其结构进行处理”。
MethodInstanceMethodInstance
解决“当前这一次具体如何执行该方法”。
5.38 与PHP面向对象逻辑的关系
Class/Object/Method工程模型与传统面向对象程序设计具有明显的结构对应关系。
例如传统面向对象中:
Class→ObjectClass\rightarrow Object
对象具有:
AttributeAttribute
并可以调用:
MethodMethod
这与结构智能的基本对象结构是一致的。
但是,WSaiOS-SI并不把 PHP 的语法规则本身作为结构智能理论。
PHP只是提供了一种成熟的工程表达方式,使:
Class→Object→Attribute→MethodClass \rightarrow Object \rightarrow Attribute \rightarrow Method
能够在程序中得到实例化。
结构智能进一步把这种对象结构扩展到:
Knowledge→Capability→Cognition→Decision→ExecutionKnowledge \rightarrow Capability \rightarrow Cognition \rightarrow Decision \rightarrow Execution
因此:
PHP OOPPHP\ OOP
可以作为工程实现参考,
但:
WSaiOS−SI Theory≠PHPWSaiOS-SI\ Theory\neq PHP
结构智能的理论对象不限于程序代码中的 Class/Object,而是用于描述现实对象、知识对象、结构对象和可运算对象。
5.39 从对象结构到结构智能
Class/Object/Method模型并不是结构智能的终点。
它是更大智能结构中的对象级基础。
完整路径为:
Element→Structure→Class→Object→Attribute→ValueElement \rightarrow Structure \rightarrow Class \rightarrow Object \rightarrow Attribute \rightarrow Value
然后:
Object→Relation→ObjectObject \rightarrow Relation \rightarrow Object
形成对象关系结构。
再:
Knowledge↔ObjectStructureKnowledge \leftrightarrow ObjectStructure
形成知识。
再:
Knowledge↔CapabilityKnowledge \leftrightarrow Capability
形成能力。
然后:
Cognition→Decision→Method→ExecutionCognition \rightarrow Decision \rightarrow Method \rightarrow Execution
最终:
Execution→Result→Feedback→Learning→EvolutionExecution \rightarrow Result \rightarrow Feedback \rightarrow Learning \rightarrow Evolution
因此 Class/Object/Method 是结构智能从“结构定义”进入“对象运算和实际行为”的关键工程层。
5.40 本章小结
Class/Object/Method工程模型建立了结构智能对象层的完整工程体系。
首先,Class作为对象的抽象结构定义:
Class={AttributeDefinition,MethodDefinition,…}Class= \{AttributeDefinition,MethodDefinition,\ldots\}
然后 Class 实例化形成具体 Object:
Class→ObjectClass\rightarrow Object
Object 具有 Attribute:
Object→AttributeObject\rightarrow Attribute
Attribute 绑定具体 Value:
Attribute→ValueAttribute\rightarrow Value
由此形成:
Object→Attribute→ValueObject\rightarrow Attribute\rightarrow Value
这是对象知识结构的基本形式。
同时 Class 中定义的方法可以作用于 Object:
Object→MethodObject\rightarrow Method
方法经过实例化:
Method→MethodInstanceMethod\rightarrow MethodInstance
绑定对象和参数:
MethodInstance→ObjectBinding→ParameterBindingMethodInstance \rightarrow ObjectBinding \rightarrow ParameterBinding
然后进行实际运算:
MethodInstance→Operation→ResultMethodInstance \rightarrow Operation \rightarrow Result
因此完整对象运算路径为:
Class→Object→Attribute→Value→Method→MethodInstance→Operation→Result\boxed{ Class \rightarrow Object \rightarrow Attribute \rightarrow Value \rightarrow Method \rightarrow MethodInstance \rightarrow Operation \rightarrow Result }
与此同时,Object之间通过 Relation 建立结构:
Object↔Relation↔ObjectObject \leftrightarrow Relation \leftrightarrow Object
形成更加完整的知识结构。
Class/Object/Method又与前面的 Knowledge、Capability、Cognition、Decision 和 Execution 相连接:
Knowledge↔ObjectKnowledge \leftrightarrow Object Knowledge↔CapabilityKnowledge \leftrightarrow Capability Cognition→Object→Attribute→ValueCognition \rightarrow Object \rightarrow Attribute \rightarrow Value Decision→Method→ExecutionDecision \rightarrow Method \rightarrow Execution
最终:
Execution→Result→Feedback→Learning→EvolutionExecution \rightarrow Result \rightarrow Feedback \rightarrow Learning \rightarrow Evolution
因此,Class/Object/Method工程模型完成了从:
结构定义 → 对象实例 → 属性值 → 方法实例 → 运算 → 结果
的工程化表达,使结构智能中的对象不仅能够被描述,而且能够被识别、绑定、计算、调用、执行和更新。
其核心统一模型可以归纳为:
Class={AttributeDefinition,MethodDefinition}\boxed{ Class = \{AttributeDefinition,MethodDefinition\} } Class→Object→Attribute→Value\boxed{ Class\rightarrow Object \rightarrow Attribute \rightarrow Value } Object→Method→MethodInstance→Operation→Result\boxed{ Object \rightarrow Method \rightarrow MethodInstance \rightarrow Operation \rightarrow Result }
并最终进入:
Result→Feedback→Learning→Evolution\boxed{ Result \rightarrow Feedback \rightarrow Learning \rightarrow Evolution }
由此,Class、Object、Attribute、Value 和 Method 不再只是程序设计中的语法对象,而成为 WSaiOS结构智能(WSaiOS-SI)理论工程 中连接 Element、Structure、Knowledge 与 Capability、Cognition、Decision、Execution 的核心对象级工程结构。