简体   繁体   English

实例和子类之间的主要区别是什么?

[英]What is the main difference between instances and sub-classes?

This question is about Ontologies , I am implementing an ontology about potential physical attacks on wireless sensors as devices.这个问题是关于本体论的,我正在实施一个关于无线传感器作为设备的潜在物理攻击的本体论。

I created class Modification_Attack meaning attacks which modify in the sensor itself.我创建了 class Modification_Attack ,意思是在传感器本身进行修改的攻击。 I created Programming_Modification as an instance of this class, is this logical, is it better a sub-class or neither an instance nor a sub-class?我创建了Programming_Modification作为这个 class 的实例,这是合乎逻辑的,它是一个子类更好还是既不是实例也不是子类更好?

What is the main difference between instances and sub-classes? 实例和子类之间的主要区别是什么?

This question isn't really unique to OWL ontologies; 这个问题并不是OWL本体真正独有的。 it comes up in object-oriented programming, and in set theory in mathematics. 它出现在面向对象的程序设计和数学的集合论中。 A class is a collection of its members. 一个类是其成员的集合。 Eg, 例如,

Person ≡ { person 1 , person 2 , … } 人≡{人1 ,人2 ,…}

Suppose you have another class: 假设您还有另一个课程:

TallPerson ≡ { person 63 , person 102 , … } TallPerson≡{人63 ,人102 ,…}

A class A is a subclass of the class B if every element of A is also an element of B: 如果A的每个元素也是B的元素,则A类是B类的子类:

(A ⊆ B) ≡ (x ∈ A → x ∈ B) (A⊆B)≡(x∈A→x∈B)

So, for instance, if every member of TallPerson is also a member of Person , then TallPerson is a subclass of Person . 因此,例如,如果TallPerson的每个成员也是Person的成员,则TallPersonPerson的子类。

I created class Modification_Attack meaning attacks which modify in the sensor itself.I created Programming_Modification as an instance of this class , is this logical , is it better a sub-class or neither an instance nor a sub-class? 我创建了Modification_Attack类,这意味着可以在传感器本身中进行修改的攻击。我创建了Programming_Modification作为此类的实例,这是逻辑上的吗,它是更好的子类,还是既不是实例又不是子类?

This is a choice that you need to make. 这是您需要做出的选择。 It really depends on the context and how you intend to use the ontology. 这实际上取决于上下文以及打算如何使用本体。 If you're observing attacks in the wild and trying to categorize them, you probably want a subclass, but you'll want to have instances of Programming_Modification . 如果您正在观察狂野的攻击并尝试对其进行分类,则可能需要一个子类,但是您将需要有Programming_Modification的 实例 That is, you'll want something like: 也就是说,您将需要以下内容:

Programming_Modification ≡ { attack 24 , attack 89 , … } Programming_Modification≡{攻击24 ,攻击89 ,…}

But if you've got some other kind of use case, where you you want to talk about Programming_Modification as a single entity, then it might make more sense for it to be an individual. 但是,如果您还有其他用例,那么您想将Programming_Modification视为单个实体,那么将其作为一个个体可能会更有意义。

I have been thinking through the same issue.我一直在思考同样的问题。 And I think the same thing can be both an instance and a subclass depending on whether you plan to use it conceptually or not, which can be simplified to whether you would describe it using the or a .而且我认为同一事物既可以是实例又可以是子类,这取决于您是否打算在概念上使用它,这可以简化为您是否会使用thea来描述它。

For example, I am working on a materials ontology, where the main class is Material .比如我在做一个materials本体,其中主要的class就是Material A particular type of material is Steel .一种特殊类型的材料是Steel If I say the steel then steel an instance of Material .如果我说钢,那么steel就是Material的一个实例 If I say a steel then Steel is a subclass of Material .如果我说,那么SteelMaterial子类 Further, steel is an instance of Steel .此外, steelSteel的一个实例 And it would be more appropriate to also give it some kind of meaningful identifier like steel-1 .并且给它一些有意义的标识符会更合适,比如steel-1

It all seems to come down whether you are using a term as a conceptual class or as a name for some instance of that class. In your case, I think it would probably be more appropriate to say Programming_Modification is a subclass as you could probably have many of such modifications which you would refer to as the first Programming_Modification or the second Programming_Modification .无论您是将术语用作概念性的 class 还是用作该 class 的某个实例的名称,这一切似乎都已解决。在您的情况下,我认为说Programming_Modification是一个子类可能更合适,因为您可能拥有您可以将许多此类修改称为first Programming_Modification第二second Programming_Modification Would love to see what you came up with though if you have a solution.如果您有解决方案,很想看看您的想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM