UML2.51邊譯邊學(xué)-組件

本文是UML規(guī)范2.5.1中組件相關(guān)部分中文翻譯。原文可從https://www.omg.org/spec/UML/2.5.1下載。
11.6.1 Summary(總結(jié))
This sub clause specifies a set of constructs that can be used to define software systems of arbitrary size and complexity.In particular, it specifies a Component as a modular unit with well-defined Interfaces that is replaceable within its environment. The Component concept addresses the area of component-based development and component-based system structuring, where a Component is modeled throughout the development life cycle and successively refined into deployment and run-time.
本節(jié)規(guī)定了一組結(jié)構(gòu),可用于定義任意大小和復(fù)雜性的軟件系統(tǒng)。特別是,它將組件規(guī)定為具有可在其環(huán)境中替換的明確定義的接口的模塊化單元。組件概念涉及基于組件的開發(fā)和基于組件的系統(tǒng)結(jié)構(gòu)領(lǐng)域,其中組件在整個(gè)開發(fā)生命周期中被建模,并連續(xù)細(xì)化到部署和運(yùn)行時(shí)。
An important aspect of component-based development is the reuse of previously constructed Components. A Component can always be considered an autonomous unit within a system or subsystem. It has one or more provided and/or required Interfaces (potentially exposed via Ports), and its internals are hidden and inaccessible other than as?provided by its Interfaces. Although it may be dependent on other elements in terms of Interfaces that are required, a Component is encapsulated and its Dependencies are designed such that it can be treated as independently as possible. As a result, Components and subsystems can be flexibly reused and replaced by connecting (“wiring”) them together.
基于組件的開發(fā)的一個(gè)重要方面是重用先前構(gòu)建的組件。組件始終可以被視為系統(tǒng)或子系統(tǒng)中的自治單元。它有一個(gè)或多個(gè)提供的和/或必需的接口(可能通過端口暴露),并且它的內(nèi)部是隱藏的,除了由其接口提供的之外,無法訪問。盡管就所需的接口而言,它可能依賴于其他元素,但組件是封裝的,并且其依賴項(xiàng)被設(shè)計(jì)為可以盡可能獨(dú)立地對待它。因此,組件和子系統(tǒng)可以通過將它們連接(“接線”)在一起來靈活地重用和替換。
The aspects of autonomy and reuse also extend to Components at deployment time. The artifacts that implement Component are intended to be capable of being deployed and re-deployed independently, for instance to update an existing system.
自治和重用的想法也在部署時(shí)擴(kuò)展到組件。實(shí)現(xiàn)組件的制品旨在能夠獨(dú)立部署和重新部署,例如更新現(xiàn)有系統(tǒng)。
The Components package supports the specification of both logical Components (e.g., business components, process components) and physical Components (e.g., EJB components, CORBA components, COM+ and .NET components, WSDL components, etc.), along with the artifacts that implement them and the nodes on which they are deployed and executed. It is anticipated that profiles based around Components will be developed for specific component technologies and associated hardware and software environments.
組件包支持定義邏輯組件(例如,業(yè)務(wù)組件、流程組件)和物理組件(例如,EJB 組件、CORBA 組件、COM+ 和 .NET 組件、WSDL 組件等),以及實(shí)現(xiàn)、部署和執(zhí)行它們的節(jié)點(diǎn)。預(yù)計(jì)將會針對特定的組件技術(shù)和相應(yīng)的硬件和軟件環(huán)境開發(fā)基于組件的配置文件。
11.6.3 Semantics(語義)
11.6.3.1 Components(組件)
A Component represents a modular part of a system that encapsulates its contents and whose manifestation is replaceable within its environment.
組件代表系統(tǒng)的模塊化部分,它封裝了其內(nèi)容并且表現(xiàn)形式在其環(huán)境中是可替換的。
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.
組件是一個(gè)獨(dú)立的單元,它封裝了許多類目的狀態(tài)和行為。組件根據(jù)其提供的和所需的接口指定了它向其客戶提供的服務(wù)以及它從系統(tǒng)中的其他組件或服務(wù)要求的服務(wù)的正式約定。
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.
一個(gè)組件是一個(gè)可替代的單元,可以在設(shè)計(jì)時(shí)或運(yùn)行時(shí)被一個(gè)組件替換,該組件提供基于其接口兼容性的等效功能。只要環(huán)境與組件提供的和所需的接口完全兼容,它就能夠與該環(huán)境進(jìn)行交互。類似地,可以通過添加新的組件類型來擴(kuò)展系統(tǒng),從而增加新的功能。系統(tǒng)功能的較大部分可以通過將組件重新用作包含組件或組件組件中的部件,并將它們連接在一起來組裝。
A Component is modeled throughout the development life cycle and successively refined into deployment and run-time. A Component may be manifested by one or more Artifacts, and in turn, that Artifact may be deployed to its execution?environment. A DeploymentSpecification may define values that parameterize the Component’s execution. (See
Deployments – Clause 19).
組件在整個(gè)開發(fā)生命周期中都被建模,并連續(xù)細(xì)化為部署和運(yùn)行時(shí)。一個(gè)組件可以由一個(gè)或多個(gè)制品表現(xiàn)出來,反過來,制品可以部署到它的執(zhí)行環(huán)境中。?部署定義可以定義參數(shù)化組件執(zhí)行的值。(參見部署 – 第 19 節(jié))。
The required and provided Interfaces of a Component allow for the specification of StructuralFeatures such as attributes and Association ends, as well as BehavioralFeatures such as Operations and Receptions. A Component may implement a provided Interface directly, or its realizing Classifiers may do so, or they may be inherited. The required and provided Interfaces may optionally be organized through Ports; these enable the definition of named sets of provided and required Interfaces that are typically (but not always) addressed at run-time.
組件所需和提供的接口允許定義結(jié)構(gòu)特征,例如屬性和關(guān)聯(lián)端,以及行為特征,例如操作和接收。一個(gè)組件可以直接實(shí)現(xiàn)一個(gè)提供的接口,或者由它的實(shí)現(xiàn)類目提供,或者它們可以被繼承。可以選擇通過端口組織所需和提供的接口;這些可以定義提供和所需接口的命名集,這些接口通常(但不總是)在運(yùn)行時(shí)定位。
A Component has an external view (or “black-box” view) by means of its publicly visible Properties and? Operations. Optionally, a Behavior such as a ProtocolStateMachine may be attached to an Interface, Port, and to the Component itself, to define the external view more precisely by making dynamic constraints in the sequence of Operation calls explicit.
組件通過其公開可見的屬性和操作提供外部視圖(或“黑盒”視圖)。可選地,可以將諸如協(xié)議狀態(tài)機(jī)之類的行為附加到接口、端口和組件本身,以定義通過明確操作調(diào)用序列中的動態(tài)約束來更精確地獲取外部視圖。
The wiring between Components in a system or other context can be structurally defined by using Dependencies between compatible simple Ports, or between Usages and matching InterfaceRealizations that are represented by sockets and lollipops (see 10.4.4) on Components on Component diagrams. Creating a wiring Dependency between a Usage and a matching InterfaceRealization, or between compatible simple Ports, means that there may be some additional information, such as performance requirements, transport bindings, or other policies that determine that the Interface is realized in a way that is suitable for consumption by the depending Component. Such additional information could be captured in a profile by means of stereotypes.
系統(tǒng)或其他上下文中的組件之間的接線可以通過使用兼容的簡單端口之間的依賴關(guān)系來結(jié)構(gòu)化定義,或者在使用和匹配的接口實(shí)現(xiàn)之間進(jìn)行定義,這些接口由組件圖中組件上的插座和棒棒糖(參見 10.4.4)表示。在使用和匹配的接口實(shí)現(xiàn)之間或在兼容的簡單端口之間創(chuàng)建接線依賴意味著可能有一些附加信息,例如性能要求、傳輸綁定或其他確定接口以某種方式實(shí)現(xiàn)的策略適合由依賴組件消耗。此類附加信息可以通過衍型在配置文件中捕獲。
A Component also has an internal view (or “white-box” view) by means of its private Properties and realizing Classifiers. This view shows how the external Behavior is realized internally. Dependencies on the external view?provide a convenient overview of what may happen in the internal view; they do not prescribe what must happen. More detailed behavior specifications such as Interactions and Activities may be used to detail the mapping from external to internal behavior.
組件還通過其私有屬性和實(shí)現(xiàn)類目具有內(nèi)部視圖(或“白盒”視圖)。該視圖顯示了外部行為是如何在內(nèi)部實(shí)現(xiàn)的。對外部視圖的依賴為內(nèi)部視圖中可能發(fā)生的事情提供了方便的概覽;它們沒有規(guī)定必須發(fā)生什么。可以使用更詳細(xì)的行為定義(例如交互和活動)來詳細(xì)說明從外部行為到內(nèi)部行為的映射。
The execution time semantics for an assembly Connector in a Component are that requests (signals and operation invocations) travel along an instance of a Connector. The execution semantics for multiple Connectors directed to and from different roles, or n-ary Connectors where n> 2, indicates that the instance that will originate or handle the request will be determined at execution time.
組件中裝配連接器的執(zhí)行時(shí)間語義是請求(信號和操作調(diào)用)沿著連接器的實(shí)例傳輸。多個(gè)連接器的執(zhí)行語義指向和來自不同角色的,或n( n> 2 )元連接器,表明將在執(zhí)行時(shí)確定將發(fā)起或處理請求的實(shí)例。
A number of UML standard stereotypes exist that apply to Component. For example, ?Subsystem? to model large-scale Components, and ?Specification? and ?Realization? to model Components with distinct specification and realization definitions, where one specification may have multiple realizations (see the Standard Profiles).
存在許多適用于組件的 UML 標(biāo)準(zhǔn)構(gòu)造型。例如,“子系統(tǒng)”對大規(guī)模組件建模,“定義”和“實(shí)現(xiàn)”對具有不同定義和實(shí)現(xiàn)的組件建模,其中一個(gè)定義可能有多個(gè)實(shí)現(xiàn)(參見標(biāo)準(zhǔn)配置文件)。
A Component may be realized (or implemented) by a number of Classifiers. In that case, a Component owns a set of ComponentRealizations to these Classifiers.
組件可以由多個(gè)類目實(shí)現(xiàn)(或?qū)嵮b)。在這種情況下,組件擁有一組針對這些分類器的組建實(shí)現(xiàn)。
A component acts like a Package for all model elements that are involved in or related to its definition, which should be either owned or imported explicitly. Typically the Classifiers that realize a Component are owned by it.
對于所有涉及或與其定義相關(guān)的模型元素,一個(gè)組件就像一個(gè)包,應(yīng)該明確擁有或?qū)搿Mǔ#瑢?shí)現(xiàn)組件的類目歸它所有。
11.6.4 Notation(記法)
A Component is shown as a Classifier rectangle with the keyword ?component?. Optionally, in the right hand corner a Component icon can be displayed. This is a Classifier rectangle with two smaller rectangles protruding from its left hand side. If the icon symbol is shown, the keyword ?component? may be hidden.
組件顯示為帶有關(guān)鍵字 ?component? 的類目矩形。或者,可以在右上角顯示一個(gè)組件圖標(biāo)。這是一個(gè)類目矩形,其左側(cè)有兩個(gè)較小的矩形突出。如果顯示圖標(biāo)符號,則可能隱藏關(guān)鍵字 ?component?。
The attributes, operations and internal structure compartments all have their normal meaning. The internal structure uses?the notation defined in StructuredClassifiers (11.2).
屬性、操作和內(nèi)部結(jié)構(gòu)分區(qū)都有其正常含義。內(nèi)部結(jié)構(gòu)使用在 StructuredClassifiers (11.2) 中定義的符號。
The provided and required Interfaces of a Component may be shown by means of ball (lollipop) and socket notation (see 10.4.4), where the lollipops and sockets stick out of the Component rectangle.
組件的提供和需要的接口可以通過球(棒棒糖)和插座符號(見 10.4.4)來表示,其中棒棒糖和插座伸出組件矩形。
For displaying the full signature of a provided or required Interface of a Component, the Interfaces can also be?displayed as normal expandable Classifier rectangles. For this option, the Interface rectangles are connected to the Component rectangle by appropriate dependency arrows, as specified in 7.7.4 and 10.4.4.
為了顯示組件提供或需要的接口的完整簽名,接口也可以顯示為正常的可擴(kuò)展類目矩形。對于此選項(xiàng),接口矩形通過適當(dāng)?shù)囊蕾嚰^連接到組件矩形,如 7.7.4 和 10.4.4 中所述。
A conforming tool may optionally support compartments named “provided interfaces” and “required interfaces” listing?the provided and required Interfaces by name. This may be a useful option in scenarios in which a Component has a large number of provided or required Interfaces.
符合標(biāo)準(zhǔn)的工具可以選擇支持名為“提供的接口”和“所需的接口”的隔間,按名稱列出提供的和所需的接口。在組件具有大量提供或需要的接口的情況下,這可能是一個(gè)有用的選項(xiàng)。
Additional optional compartments “realizations” and “artifacts” may be used to list the realizing Classifiers (Classifiers reached by following the realization property) and manifesting Artifacts (Artifacts that manifest this component – see 19.3).
額外的可選隔間“實(shí)現(xiàn)”和“制品”可用于列出實(shí)現(xiàn)類目(通過遵循實(shí)現(xiàn)屬性到達(dá)的類目)和顯示制品(顯示該組件的制品?- 參見 19.3)。
A ComponentRealization is notated in the same way as a Realization dependency (i.e., as a general dashed line with a hollow triangle as an arrowhead).
組件實(shí)現(xiàn)以與實(shí)現(xiàn)依賴項(xiàng)相同的方式表示(即,作為帶有空心三角形作為箭頭的一般虛線)。
The packagedElements of a Component may be displayed in an optional compartment named “packaged elements,” according to the specification for optional compartments for ownedMembers set out in 9.2.4.
根據(jù) 9.2.4 中規(guī)定的擁有成員的可選隔間的規(guī)范,組件的 packagedElements 可以顯示在名為“packaged elements”的可選隔間中。
11.6.5 Examples(示例)
An overview diagram can show Components related by Dependencies, which signify some further unspecified kind of dependency between the components, and by implication a lack of dependency where there are no Dependency arrows.
概覽圖可以顯示由依賴關(guān)系相關(guān)的組件,這意味著組件之間存在某種進(jìn)一步未指定的依賴關(guān)系,并暗示在沒有依賴關(guān)系箭頭的情況下不存在依賴關(guān)系。

Figure 11.40 shows an external (“black-box”) view of a Component by means of interface lollipops and sockets sticking out of the Component rectangle.
圖 11.40 顯示了一個(gè)組件的外部(“黑盒”)視圖,通過接口棒棒糖和從組件矩形伸出的插座。

Figure 11.41 shows provided and required interfaces listed in optional compartments.
圖 11.41 顯示了在可選隔間中列出的提供和需要的接口。

Figure 11.42 shows a “white box” view of a Component listing realizing Classifiers and manifesting Artifacts in?additional optional compartments.
圖 11.42 顯示了一個(gè)組件列表的“白盒”視圖,它實(shí)現(xiàn)了分類器并在額外的可選隔間中顯示了工件。

Figure 11.43 shows explicit representation of the provided and required Interfaces using Dependency notations, allowing Interface details such as Operations to be displayed.
圖 11.43 使用依賴符號顯示了提供的和所需的接口的顯式表示,允許顯示諸如操作之類的接口詳細(xì)信息。

Figure 11.44 shows a set of Classifiers that realize a Component with realization arrows representing the ComponentRealizations.
圖 11.44 顯示了一組實(shí)現(xiàn)組件的類目,實(shí)現(xiàn)箭頭表示組建實(shí)現(xiàn)。

Figure 11.45 shows owned Classes that realize a Component nested within an optional “packaged elements” compartment of the Component shape.
圖 11.45 顯示了擁有的類,這些類實(shí)現(xiàn)了嵌套在組件形狀的可選“打包元素”隔間中的組件。

Figure 11.46 shows various ways of wiring Components using Dependencies.
圖 11.46 顯示了使用依賴關(guān)系連接組件的各種方式。
The Dependency on the right of the figure is from the Usage of OrderableItem to the InterfaceRealization of?OrderableItem. This also shows that “/OrderableItem” is an Interface that is implemented by a supertype of Product, following the notation specified in 10.4.4.
The Dependency between the AccountPayable Ports illustrates the notational option of showing the dependency arrow joining the socket to the lollipop, when a Dependency is wired between simple Ports.
圖中右邊的Dependency是從OrderableItem的使用到OrderableItem的接口實(shí)現(xiàn)。這也表明“/OrderableItem”是一個(gè)由 Product 的超類型實(shí)現(xiàn)的接口,遵循 10.4.4 中指定的符號。
When realizing Classifiers are shown in a packaged elements compartment, a Dependency may be shown from a simple Port to a realizing Classifier to indicate that the Interface provided or required by the Port is dependent in some way upon the Classifier. This is illustrated by the Dependency from AccountPayable to OrderHeader, which indicates that something about the fact that the Component requires AccountPayable is dependent upon OrderHeader.
當(dāng)實(shí)現(xiàn)類目顯示在封裝元素隔間中時(shí),可以從簡單端口到實(shí)現(xiàn)類目顯示依賴關(guān)系,以指示端口提供或所需的接口以某種方式依賴于類目。從 AccountPayable 到 OrderHeader 的依賴關(guān)系說明了這一點(diǎn),這表明組件需要 AccountPayable 的事實(shí)依賴于 OrderHeader。

Figure 11.47 shows an internal or white-box view of the internal structure of a Component that contains other Components with simple Ports as parts of its internal assembly. The assembly Connectors use ball-and-socket notation. The delegation connectors use the notational option that the Connector line can end on the ball or socket, rather than the simple port itself.
圖 11.47 顯示了一個(gè)組件的內(nèi)部結(jié)構(gòu)的內(nèi)部或白盒視圖,該組件包含其他具有簡單端口的組件作為其內(nèi)部組件的一部分。裝配連接器使用球窩符號。委托連接器使用符號選項(xiàng),連接器線可以在球或插座上結(jié)束,而不是簡單的端口本身。

Figure 11.48 shows delegation Connectors from delegating Ports to handling parts; in this example the parts in the internal structure compartment are typed by Classes shown in the optional packaged elements compartment.
圖 11.48 顯示了從委派端口到處理部件的委派連接器;在此示例中,內(nèi)部結(jié)構(gòu)隔間中的部件按可選包裝元素隔間中顯示的類鍵入。

作者著作介紹
《實(shí)戰(zhàn)Python設(shè)計(jì)模式》是作者去年3月份出版的技術(shù)書籍,該書利用Python 的標(biāo)準(zhǔn)GUI 工具包tkinter,通過可執(zhí)行的示例對23 個(gè)設(shè)計(jì)模式逐個(gè)進(jìn)行說明。這樣一方面可以使讀者了解真實(shí)的軟件開發(fā)工作中每個(gè)設(shè)計(jì)模式的運(yùn)用場景和想要解決的問題;另一方面通過對這些問題的解決過程進(jìn)行說明,讓讀者明白在編寫代碼時(shí)如何判斷使用設(shè)計(jì)模式的利弊,并合理運(yùn)用設(shè)計(jì)模式。

對設(shè)計(jì)模式感興趣而且希望隨學(xué)隨用的讀者通過本書可以快速跨越從理解到運(yùn)用的門檻;希望學(xué)習(xí)Python GUI 編程的讀者可以將本書中的示例作為設(shè)計(jì)和開發(fā)的參考;使用Python 語言進(jìn)行圖像分析、數(shù)據(jù)處理工作的讀者可以直接以本書中的示例為基礎(chǔ),迅速構(gòu)建自己的系統(tǒng)架構(gòu)。
覺得本文有幫助?請分享給更多人。
關(guān)注微信公眾號【面向?qū)ο笏伎肌枯p松學(xué)習(xí)每一天!
面向?qū)ο箝_發(fā),面向?qū)ο笏伎迹?/span>
