Java UML 格式的服务器页面 (.JSP) 文件 Class 图
Java Server Pages (.JSP) files in UML Class Diagrams
我正在为即将开始的项目编写设计,我想知道我应该如何在 UML class 图表中表示视图(jsp 文件)已经创造出来了。由于 jsp 个文件不是 class 文件,它们适合放在这里吗?我不这么认为,因为这是一个 class 图,但我不确定我应该如何表示这些,有什么想法吗?
JSP 文件被认为是视图文件,它们不是实际的 functions/methods。因此,它们应该 NOT 包含在 UML class 图中。
一切都取决于您使用 UML 的环境。
在UML distilled中,Martin Fowler区分了三种使用UML的方式:
- 蓝图(UML用于软件开发过程)
- 草图(UML用于系统的细节)
- 可执行 UML(UML 的一种使用,其中 UML 是程序的持久源,在代码之前)
出于逻辑原因,大多数软件开发过程(蓝图模式)不允许您在 class 图中包含视图组件:UML 是关于 OOP. This is also the case in executable UML, in other words this is what user1556242 的。
在蓝图或可执行 UML 模式下,唯一允许在其中表示视图组件的 UML 图是 the component diagram and the the deployment diagram:这些图不显示特定于对象的功能。
但是,如果您处于草图模式,这是您在图表中包含 JSP 页面的合法权利,但这不应该是视图组件形式。在 class 图表中,您应该表示 classes。您不应表示 JSP 页面本身,而应表示其对象形式。 JSP 在运行时被翻译成 servlet class(参见 Wikipedia article), in Tomcat this is done via Jasper。
对不起,我不完全同意其他答案,从纯 UML 的角度来说。从这个角度来看,jsp 文件是工件的一个示例,它是 class 的一种类型。 jsp 文件的一个实例是一个对象,它与 Servlet 具有特定的“清单”关系(这里借用了 bdulac 的回答;我不是 Java Web 方面的专家)。
来自 UML 规范(Superstructure v2.0,第 193 页):
10.3.1 Artifact (from Artifacts, Nodes)
An artifact is the specification of a physical piece of information that is used or produced by a software development process, or by deployment and operation of a system. Examples of artifacts include model files, source files, scripts, and binary executable files, a table in a database system, a development deliverable, or a word-processing document, a mail message.
再往下:
In the metamodel, an Artifact is a Classifier that represents a physical entity. Artifacts may have Properties that represent features of the Artifact, and Operations that can be performed on its instances. Artifacts can be involved in Associations to other Artifacts (e.g., composition associations). Artifacts can be instantiated to represent detailed copy semantics, where different instances of the same Artifact may be deployed to various Node instances (and each may have separate property values, e.g., for a ‘time-stamp’ property).
并且:
An Artifact defined by the user represents a concrete element in the physical world. A particular instance (or ‘copy’) of an artifact is deployed to a node instance. Artifacts may have composition associations to other artifacts that are nested within it. For instance, a deployment descriptor artifact for a component may be contained within the artifact that implements that component. In that way, the component and its descriptor are deployed to a node instance as one artifact instance.
Specific profiles are expected to stereotype artifact to model sets of files (e.g., as characterized by a ‘file extension’ on a file system). The UML Standard Profile defines several standard stereotypes that apply to Artifacts, e.g., «source» or «executable» (See Annex C - Standard Stereotypes). These stereotypes can be further specialized into implementation and platform specific stereotypes in profiles. For example, an EJB profile might define «jar» as a subclass of «executable» for executable Java archives.
并且,JavaWeb 配置文件可能将 «jsp» 定义为扩展 «file» 的原型。
最后:
Changes from previous UML
The following changes from UML 1.x have been made: Artifacts can now manifest any PackageableElement (not just Components, as in UML 1.x).
虽然一个工件通常会显示一个组件,但没有理由说它不能显示一个 class(它也是“一个”PackageableElement)。这就是为什么他们取消了工件只能显示组件的限制。因此,纯粹从 UML 的角度来看,jsp 文件是 class,因此可以是 class 图的一部分。
这样做是否有意义是另一个问题,但不能不经调查就忽略它。
我正在为即将开始的项目编写设计,我想知道我应该如何在 UML class 图表中表示视图(jsp 文件)已经创造出来了。由于 jsp 个文件不是 class 文件,它们适合放在这里吗?我不这么认为,因为这是一个 class 图,但我不确定我应该如何表示这些,有什么想法吗?
JSP 文件被认为是视图文件,它们不是实际的 functions/methods。因此,它们应该 NOT 包含在 UML class 图中。
一切都取决于您使用 UML 的环境。
在UML distilled中,Martin Fowler区分了三种使用UML的方式:
- 蓝图(UML用于软件开发过程)
- 草图(UML用于系统的细节)
- 可执行 UML(UML 的一种使用,其中 UML 是程序的持久源,在代码之前)
出于逻辑原因,大多数软件开发过程(蓝图模式)不允许您在 class 图中包含视图组件:UML 是关于 OOP. This is also the case in executable UML, in other words this is what user1556242 的。
在蓝图或可执行 UML 模式下,唯一允许在其中表示视图组件的 UML 图是 the component diagram and the the deployment diagram:这些图不显示特定于对象的功能。
但是,如果您处于草图模式,这是您在图表中包含 JSP 页面的合法权利,但这不应该是视图组件形式。在 class 图表中,您应该表示 classes。您不应表示 JSP 页面本身,而应表示其对象形式。 JSP 在运行时被翻译成 servlet class(参见 Wikipedia article), in Tomcat this is done via Jasper。
对不起,我不完全同意其他答案,从纯 UML 的角度来说。从这个角度来看,jsp 文件是工件的一个示例,它是 class 的一种类型。 jsp 文件的一个实例是一个对象,它与 Servlet 具有特定的“清单”关系(这里借用了 bdulac 的回答;我不是 Java Web 方面的专家)。
来自 UML 规范(Superstructure v2.0,第 193 页):
10.3.1 Artifact (from Artifacts, Nodes)
An artifact is the specification of a physical piece of information that is used or produced by a software development process, or by deployment and operation of a system. Examples of artifacts include model files, source files, scripts, and binary executable files, a table in a database system, a development deliverable, or a word-processing document, a mail message.
再往下:
In the metamodel, an Artifact is a Classifier that represents a physical entity. Artifacts may have Properties that represent features of the Artifact, and Operations that can be performed on its instances. Artifacts can be involved in Associations to other Artifacts (e.g., composition associations). Artifacts can be instantiated to represent detailed copy semantics, where different instances of the same Artifact may be deployed to various Node instances (and each may have separate property values, e.g., for a ‘time-stamp’ property).
并且:
An Artifact defined by the user represents a concrete element in the physical world. A particular instance (or ‘copy’) of an artifact is deployed to a node instance. Artifacts may have composition associations to other artifacts that are nested within it. For instance, a deployment descriptor artifact for a component may be contained within the artifact that implements that component. In that way, the component and its descriptor are deployed to a node instance as one artifact instance.
Specific profiles are expected to stereotype artifact to model sets of files (e.g., as characterized by a ‘file extension’ on a file system). The UML Standard Profile defines several standard stereotypes that apply to Artifacts, e.g., «source» or «executable» (See Annex C - Standard Stereotypes). These stereotypes can be further specialized into implementation and platform specific stereotypes in profiles. For example, an EJB profile might define «jar» as a subclass of «executable» for executable Java archives.
并且,JavaWeb 配置文件可能将 «jsp» 定义为扩展 «file» 的原型。
最后:
Changes from previous UML
The following changes from UML 1.x have been made: Artifacts can now manifest any PackageableElement (not just Components, as in UML 1.x).
虽然一个工件通常会显示一个组件,但没有理由说它不能显示一个 class(它也是“一个”PackageableElement)。这就是为什么他们取消了工件只能显示组件的限制。因此,纯粹从 UML 的角度来看,jsp 文件是 class,因此可以是 class 图的一部分。
这样做是否有意义是另一个问题,但不能不经调查就忽略它。