实体和类有什么区别?

发布于 2024-08-27 17:13:45 字数 16 浏览 5 评论 0 原文

实体是类的实例吗?

Is entity an instance of class?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

汹涌人海 2024-09-03 17:13:45

是对象(除其他外)的模板,并且是一个非常普遍的概念。

一个实体具有更多的语义意义,并​​且通常与一个概念相关(可能与一个真实的对象有关,例如员工学生音乐专辑)并与业务逻辑相关联。

实体通常用于建立对象与数据库中的表之间的映射。实体也称为域对象。正如我之前提到的,实体将用于存在业务逻辑的情况,因此它保存有关它正在建模的系统(或系统的一部分)的信息。

A class is a template for an object (among other things), and is a very general concept.

An entity has more semantic significance and is usually tied to a concept (possibly about a real object for example, an Employee or a Student or a Music Album) and is linked to business logic.

Entities are usually used to establish a mapping between an object and to a table in the database. Entities are also known as domain objects. Like I mentioned before, entities will be used in situations where there is business logic and as such it hold information about the system (or part of the system) that it is modeling.

银河中√捞星星 2024-09-03 17:13:45

再补充一点,

是一个句法,即一组或类别的事物具有某些共同的属性或属性,并通过种类、类型或质量与其他事物区分开来。

实体是一种语义,即与语言或逻辑中的含义相关。 实体是指本身存在的东西,无论是实际的还是潜在的、具体的还是抽象的、物理的还是非物理的。它不一定是物质存在。

Object是一个由标识符引用的内存值,它是一个类的实例。

输入图像描述这里

To add one more point

Class is a syntactic i.e. A set or category of things having some property or attribute in common and differentiated from others by kind, type, or quality.

Entity is a semantic i.e. relating to meaning in language or logic. An entity is something that exists in itself, actually or potentially, concretely or abstractly, physically or not. It needs not be of material existence.

Object is a in-memory value referenced by identifier, it is an instance of a Class.

enter image description here

面如桃花 2024-09-03 17:13:45

实体通常指的是具有独特且独立存在的事物,实际上是任何事物。

在软件开发中,这个词几乎仅用于表示一个实例与另一个实例不同,并且它们彼此独立。

另一方面,定义或包含对象的定义。一旦根据定义构造了该对象,您就可以获得实例对象实例

An entity usually refers to something, anything really, that has a unique and separate existence.

In software development this word is almost only used to denote that one instance is different from another instance and they are independent of each other.

A class, on the other hand, defines or contains the definition of an object. Once that object is constructed based on the definition, then you get your instance or object instance.

时光无声 2024-09-03 17:13:45

简短——是的。

实体更多的是来自现实世界的概念。
实例(别名是对象)——来自编程世界。

在编程世界中,我们也有一个“实体”概念,但这里它更多的是实例的子级。所以任何实体都是实例的子实体。此外,实体还具有与其他事物的链接,但编程除外 - 例如,正如人们所说 - 实体可以在数据库中拥有表。
实例在数据库中不能有表。因为实例总是与类相连。

Short -- yes.

Entity is more a concept from real world.
Instance (alias is object) -- from programming world.

In programming world we also has an "entity" concept, but here it's more a child of an instance. So any entity is a child of instance. Also entity has it's links to other things but programming -- for example, as people said -- entity can have table in DB.
Instance can't have table in DB. As instance is always connected to class.

浮华 2024-09-03 17:13:45

实体

实体是轻量级持久域对象。通常,实体代表关系数据库中的一张表,每个实体实例对应于该表中的一行。实体的主要编程工件是实体类,尽管实体可以使用帮助器类。
实体的持久状态通过持久字段或持久属性来表示。这些字段或属性使用对象/关系映射注释将实体和实体关系映射到底层数据存储中的关系数据。

实体类具有实体的构造型。实体类本质上是数据库表的对象包装器。实体的属性被转换为数据库表上的列。实体可以进行各种数据维护操作,例如读取、插入、修改、删除、readmulti(read multi 根据部分键从表中读取多条记录)。

实体可以具有属性、操作、依赖关系、继承关系和聚合。一组规则与这些构造中的每一个相关联。

  • 实体类规则
    实体必须至少具有一种属性。例外情况是该实体是另一个实体的子类,在这种情况下该实体必须没有属性。实体不允许聚合其他类。

  • 实体属性
    实体属性对应于其关联数据库表中具有相同名称的列。

  • 实体运营
    实体操作根据构造型可以分为两类:数据库操作和非数据库操作。

  • 实体输出
    实体类被转换为有操作但没有属性的类。输入元模型中实体的属性将转换为一个或多个结构。

  • 实体类选项
    实体类可用的选项包括实体类抽象、允许乐观锁定、审核字段、启用验证、上次更新字段、不生成 SQL 和替换超类。

  • 并发控制的乐观锁定
    使用乐观锁进行并发控制意味着多个用户可以同时访问一条记录,但只有其中一个用户可以提交对该记录的更改。

  • 表级审计
    使用数据库表级审核选项启用表级审核。

  • 退出点
    退出点是您编写的回调函数。它由服务器在预定义的策略点执行。

  • 实体继承
    输入元模型实体类可以子类化其他实体类。

  • 上次更新字段
    最后更新的字段是您可以添加到数据库表中的字段,以包含有关每条记录的修改时间的额外信息以用于报告目的。

您还可以检查此链接和此链接更多信息!

Entities

An entity is a lightweight persistence domain object. Typically an entity represents a table in a relational database, and each entity instance corresponds to a row in that table. The primary programming artifact of an entity is the entity class, although entities can use helper classes.
The persistent state of an entity is represented either through persistent fields or persistent properties. These fields or properties use object/relational mapping annotations to map the entities and entity relationships to the relational data in the underlying data store.

Entity classes have a stereotype of entity. An entity class is essentially an object wrapper for a database table. The attributes of an entity are transformed to columns on the database table. Entities can have various data maintenance operations such as read, insert, modify, remove, readmulti (read multi reads multiple records from a table based on a partial key).

Entities can have attributes, operations, dependencies, inherits relations, and aggregations. A set of rules is associated with each of these constructs.

  • Entity class rules
    Entities must have at least one attribute. The exception is if the entity is a subclass of another entity, in which case the entity must have no attributes. Entities are not allowed to aggregate other classes.

  • Entity attributes
    Entity attributes correspond to columns with the same name on their associated database table.

  • Entity operations
    Entity operations can be divided into two categories as determined by their stereotype: database and non-database operations.

  • Entity outputs
    Entity classes are transformed into classes with operations and no attributes. The attributes from the entity in the input meta-model are transformed into one or more structs.

  • Entity class options
    The options available for entity classes are entity class abstracts, allow optimistic locking, audit fields, enable validation, last updated field, No Generated SQL, and replace superclass.

  • Optimistic locking for concurrency control
    Using optimistic locking for concurrency control means that more than one user can access a record at a time, but only one of those users can commit changes to that record.

  • Table-level auditing
    Use the Database table-level auditing option to enable table-level auditing.

  • Exit points
    An exit point is a callback function that you write. It is executed at a predefined strategic point by the server.

  • Entity inheritance
    Input meta-model entity classes can subclass other entity classes.

  • Last updated field
    The last updated field is a field that you can add to database tables to contain extra information about the modification time of each record for reporting purposes.

Also you can check this link and this link for more information!

人间☆小暴躁 2024-09-03 17:13:45

对象是具有状态、行为和身份的实体。结构和
相似对象的行为在其公共类中定义。术语实例
object 是可以互换的。

来自 Grady Booch 书

所以我们可以说,实体、对象和类实例是可以互换的。

An object is an entity that has state, behavior, and identity. The structure and
behavior of similar objects are defined in their common class. The terms instance
and object are interchangeable.

From Grady Booch book.

So we could say, that entity, object and class instance are interchangeable.

花辞树 2024-09-03 17:13:45

我从这篇论文复制,“基于实体的编程范式”,尼米特·辛哈尼亚.宾夕法尼亚大学:

实体是一个抽象单位,代表一组
节点或子实体。它使用其提供的服务
子实体以及这些子实体之间的协作
实现其所需的目标。它有自己的身份并出现
就像在现实中一样,作为外部世界的一个整体
团队或组织是一个整体,而不仅仅是一个
个人的集合。分布式系统本质上是
实体的层次结构,其中每个实体都有特定的角色
并提供特定服务[...]

[...]实体抽象与对象中的对象非常相似
面向编程。对象之间的主要区别
实体是一个活跃的、有生命的实体
单位,而对象是被动的。实体由活动的子实体组成
相互交互以提供服务并
可以与其他实体交互。鉴于,一个
对象仅包含静态字段和属性,可以
受到外界的质疑和操纵。但是,很多
可以携带面向对象编程的见解
到这个编程范例。我们可以上课
和实体类型,其中类可能提供特定的
系统其余部分的服务和功能。还,
我们可以定义实现核心的抽象实体
结构和一些基本的交互协议
节点,这些可以进一步扩展以实现实际的
实体。类似地,我们可以定义接口来定义
一组服务。这些接口可以通过以下方式实现
具有不同担保的多个实体并基于
需求,程序员可以选择其中之一
提供所需的服务。

I copy from this paper, "Entity based Programming Paradigm", Nimit Singhania. University of Pennsylvania:

An entity is an abstract unit that represents a group of
nodes or sub-entities. It uses the services provided by its
sub-entities and collaboration between these sub-entities to
achieve its required goals. It has its own identity and appears
as a single unit to the external world just as in real
life a team or an organization is a whole unit and not just a
collection of individuals. A distributed system is essentially
a hierarchy of entities where each entity has a specific role
and provides specific services [...]

[...]The entity abstraction is very similar to an object in object
oriented programming. The key difference between an object
and an entity is that an entity is an active and a live
unit while an object is passive. An entity consists of live subentities
interacting with each other to provide a service and
can possibly interact with the other entities. Whereas, an
object consists of only static fields and properties that can be
queried and manipulated by the external world. But, many
insights from object oriented programming can be carried
over to this programming paradigm. We can have classes
and types of entities, where a class might provide specific
services and functionality to the rest of the system. Also,
we could define abstract entities which implement the core
structure and some basic protocols for interaction between
nodes and these could be extended further to realize the actual
entities. Similarly, we could define interfaces that define
a set of services. These interfaces could be implemented by
multiple entities with different guarantees and based on the
requirements, one of them could be chosen by the programmer
to provide the required service.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文