简体   繁体   English

组件图是否仅指物理组件?

[英]Do Component diagrams refer to physical components only?

Is it true that a good test for whether something qualifies as a "component" in a UML component diagram, is that it's physically isolated?在 UML 组件图中,一个很好的测试是否有资格作为“组件”,它是否是物理隔离的?

Most definitions I've found (Wikipedia, TutorialsPoints,..) refer to the components as "files, libraries, executables, etc."我发现的大多数定义(Wikipedia、TutorialsPoints 等)都将组件称为“文件、库、可执行文件等”。

However, some illustrations (see http://agilemodeling.com/artifacts/componentDiagram.htm ) seem to model classes as components (eg "Student," "Seminar") which at first glance might give the indication that these are just some important classes in the application.然而,一些插图(参见http://agilemodeling.com/artifacts/componentDiagram.htm )似乎将类建模为组件(例如“学生”、“研讨会”),乍一看可能表明这些只是一些重要的应用程序中的类。 However, reading further down under the heading "Creating Component Diagrams", it makes a lot of references to "network traffic" ("reduce the potential network traffic");然而,阅读进一步下跌“创建组件图”的标题下,这让很多以“网络流量”(“降低潜在的网络流量”)引用的; the implication being that the components as modeled are distinct processes or executables that communicate via network ports.这意味着建模的组件是通过网络端口进行通信的不同进程或可执行文件。 This seems to imply that individual classes whose instances are in the same JVM (and I might add the same physical .jar) should be in the same component in the UML Component diagram.这似乎意味着实例在同一个 JVM 中的各个类(我可能会添加相同的物理 .jar)应该在 UML 组件图中的同一个组件中。 Is this always true?这总是真的吗? If not when are the cases where object instances in the same jar and same JVM would be seen as different components in this diagram?如果不是,什么时候同一个 jar 和同一个 JVM 中的对象实例会在这个图中被视为不同的组件?

No, a UML Component is not limited to physical file or something like that.不,UML 组件不限于物理文件或类似的东西。

Physical might not even be a good term to talk about files on a system as you can't really touch a file.物理甚至可能不是谈论系统上文件的好术语,因为您无法真正接触文件。 It's all just bits and bytes.这只是位和字节。

UML 2.5 defines a component as UML 2.5 将组件定义为

A Component represents a modular part of a system that encapsulates its contents and whose manifestation is replaceable within its environment.组件代表系统的模块化部分,它封装了其内容并且其表现形式在其环境中是可替换的。

Furthermore it says此外它说

A Component is a self-contained unit that encapsulates the state and behavior of a number of Classifiers.组件是一个独立的单元,它封装了许多分类器的状态和行为。 A Component specifies a formal contract of the services that it provides to its clients and those that it requires from other Components or services in the system in terms of its provided and required Interfaces.组件根据其提供的和所需的接口指定了它向其客户提供的服务以及它从系统中的其他组件或服务要求的服务的正式合同。

A Component is a substitutable unit that can be replaced at design time or run-time by a Component that offers equivalent functionality based on compatibility of its Interfaces.一个组件是一个可替代的单元,可以在设计时或运行时被一个组件替换,该组件提供基于其接口兼容性的等效功能。 As long as the environment is fully compatible with the provided and required Interfaces of a Component, it will be able to interact with this environment.只要环境与组件提供的和所需的接口完全兼容,它就能够与该环境进行交互。 Similarly, a system can be extended by adding new Component types that add new functionality.类似地,可以通过添加新的组件类型来扩展系统,从而增加新的功能。 Larger pieces of a system's functionality may be assembled by reusing Components as parts in an encompassing Component or assembly of Components, and wiring them together.系统功能的较大部分可以通过重新使用组件作为包含组件或组件组件中的部件,并将它们连接在一起来组装。

So a software application such as Skype or Chrome can be modeled as a component, but also the internal parts such as the chat engine , or the HTML renderer can be considered components.因此,可以将SkypeChrome等软件应用程序建模为组件,但也可以将聊天引擎HTML 渲染器等内部部件视为组件。

Often the component structure is actually mirrored in the physical implementation;通常,组件结构实际上反映在物理实现中; each component of a piece of software could be compiled into a single dll一个软件的每个组件都可以编译成一个单独的 dll

In addition to excellent Geert's answer, it is often a good idea to encapsulate what normally seems like a class with all things related to it as a component when you don't necessarily always need it.除了出色的 Geert 的回答之外,当您不一定总是需要它时,将通常看起来像一个类的所有内容封装为一个组件通常是一个好主意。

Imagine an application that enables managing company fleet.想象一个能够管理公司车队的应用程序。 Typically it will come with support for cars.通常它会支持汽车。 Yet you may want to be able to add additional components, to be able to handle planes, ships or bikes.然而,您可能希望能够添加额外的组件,以便能够处理飞机、轮船或自行车。 You may as well not need cars in such cases.在这种情况下,您也可能不需要汽车。 Each of those things will become components, even though you can model it simply as subclasses of the only class that resides in the system core called Vehicle.这些东西中的每一个都将成为组件,即使您可以简单地将其建模为驻留在称为 Vehicle 的系统核心中的唯一类的子类。 For instance you may have different elements related to those bikes, that are not enclosed in the class itself.例如,您可能有与这些自行车相关的不同元素,这些元素并未包含在类本身中。 Consider how different will be screens, maintenance models, everything related to different methods that can be applied on the sub-class level only.考虑一下屏幕、维护模型以及与只能应用于子类级别的不同方法相关的所有内容的不同之处。

Other example of component in such systems can be Drivers.此类系统中组件的其他示例可以是驱动程序。 This is no longer a sub-class of Vehicle but some separate class that interacts with Vehicles.这不再是 Vehicle 的子类,而是一些与 Vehicles 交互的单独类。 Again, depending on the situation you might be interested only in Cars that are in the company or have them linked to Drivers who are assigned to them or even allowed to use them.同样,根据情况,您可能只对公司中的汽车感兴趣,或者将它们链接到分配给它们甚至允许使用它们的驱动程序。 Thus you come up with an entirely different set of dependencies, screens, methods etc. which are not just related to the Driver itself, but it's interaction with the surroundings.因此,您提出了一组完全不同的依赖项、屏幕、方法等,它们不仅与驱动程序本身有关,而且与周围环境的交互有关。

In general while this is not limited to that, Component is a good way of thinking how can you split your system into smaller parts that can be detached or attached to the system adding or removing accordingly part of its functionality.一般来说,虽然这不限于此,组件是一种很好的思考方式,可以思考如何将您的系统分成更小的部分,这些部分可以分离或附加到系统上,相应地添加或删除其部分功能。

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

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