Bab 11 component diagram 2010

51
BAB XI BAB XI Component Diagram Component Diagram

Transcript of Bab 11 component diagram 2010

Page 1: Bab 11 component diagram 2010

BAB XIBAB XIComponent DiagramComponent Diagram

Page 2: Bab 11 component diagram 2010

Component Diagram

• Component diagram menggambarkan struktur danhubungan antar komponen piranti lunak, termasukketergantungan (dependency) diantaranya.

• Komponen piranti lunak : modul berisi code, baik berisisource code maupun binary code, baik library maupunexecutable, baik yang muncul pada compile time, link time maupun run time.

• Umumnya komponen terbentuk dari beberapa class danatau package, tapi dapat juga berupa interface, yaitukumpulan layanan yang disediakan sebuah komponenuntuk komponen lainnya.

Page 3: Bab 11 component diagram 2010

Component DiagramComponent Diagram

-- BersifatBersifat statisstatis- Merancang produk

-- MemperlihatkanMemperlihatkan organisasiorganisasi sertasertakebergantungankebergantungan padapada komponenkomponen--komponenkomponen yang yang telahtelah adaada sebelumnyasebelumnya

-- BerhubunganBerhubungan dengandengan diagram diagram kelaskelas..

Page 4: Bab 11 component diagram 2010

Component Diagram

• Menggambarkan alokasi semua class dan object kedalamkomponen dalam desain fisik system software, termasukpengaturan dan kebergantungan antar komponen software

• Component dapat terdiri dari– logical component, seperti business component, process

component, dll– Physical component (software arsitektur) , seperti Com+, dot

NET,CORBA, dll

• Component digambarkandengan bentuk pada UML versi 1.*:

• Pada UML versi 2 digambarkan dengan bentuk

atau atau atau

Page 5: Bab 11 component diagram 2010

• Stereotypes yang dapat digambarkan pada bentuk component<<application>>,kumpulan aplikasi system <<executable>>,component yang jalan di client<<file>>, data file

<<infrastructure>>, technical component didalam system<<source code>>, source file<<table>>, table data dalam sebuah database

<<UI>>, User interface (screen, pages, report)dll

<<database>><<document>><<library>><<web service>><<XML DTD>>

Page 6: Bab 11 component diagram 2010

Component Diagram

Dependencies• dimodelkan dengan garis terputus dengan panah terbuka • gambarkan dependencies dari kiri ke kanan

Contoh:<<ASP>> Source Code bergantung pada<<database>> MySQL

• Dimungkinkan sebuah component dependencies pada interfaces component lainnyaContoh:

Inheritance• inheriting/child component diletakkan dibawah parent component, dengan

arah panah menuju ke parent component• dimodelkan dengan garis dengan panah tertutup Contoh:

Page 7: Bab 11 component diagram 2010

Interfaces - Component Diagram

• Interfaces adalah kumpulan >=1 methode dan >=0 attribute yang dapatdipakai pada class tanpa menjadi behavior suatu class.

• Jenis interface ada 2 macam yaitu :– Provide, digambarkan dengan bentuk lollipop

Pada UML 1.* bisa juga digambarkan dengan garis terputus d enganpanah tertutup

– Required, digambarkan dengan bentuk socket• Penggambaran

interfaces dapat jugadilakukan denganmenambah bagiancomponent seperticontoh dibawah ini

Bentuk grafik

Page 8: Bab 11 component diagram 2010

Component Diagram

port• adalah bentuk object yang menjelaskan interaksi antara object dan

lingkungannya• digambarkan sebagai kotak kecil di pinggiran component <<component>>

OrderAssembly connector• Penghubung antara

2/lebih component dimanasebuah/beberapacomponent provides interfaces dancomponent lain required interfaces

• Digambarkan dengangabungan bentukinterfacescontoh:

Page 9: Bab 11 component diagram 2010

Penggunaan Component Diagrams

• When you model the static implementation view of a system, you'll typically use component diagrams in one of four ways

– To model source code– To model executable releases– To model physical databases– To model adaptable systems

Page 10: Bab 11 component diagram 2010

Modeling Source Code• Either by forward or reverse engineering, identify

the set of source code files of interest and model them as components stereotyped as files.

• For larger systems, use packages to show groups of source code files.

• Model the compilation dependencies among these files using dependencies. Again, use tools to help generate and manage these dependencies.

Page 11: Bab 11 component diagram 2010

Modeling Source Code (cont.)

Page 12: Bab 11 component diagram 2010

Modeling an Executable Release

• Executable Release– main executable (usually, a .exe file)– libraries (commonly .dll files if you are working

in the context of COM+, or .class and .jar files if you are working in the context of Java)

– Databases– help files, and resource files

Page 13: Bab 11 component diagram 2010

Modeling an Executable Release

• To model an executable release– Identify the set of components you'd like to

model. – Consider the stereotype of each component

in this set. (such as executables, libraries, tables, files, and documents)

– For each component in this set, consider its relationship to its neighbors

Page 14: Bab 11 component diagram 2010

Modeling an Executable

Release

Page 15: Bab 11 component diagram 2010

Modeling a Physical Database• To model a physical database

– Identify the classes in your model that represent your logical database schema

– Select a strategy for mapping these classes to tables. Use one of three strategies :• Define a separate table for each class• Collapse your inheritance lattices so that all instances

of any class in a hierarchy has the same state• Separate parent and child states into different tables

Page 16: Bab 11 component diagram 2010

Modeling a Physical Database

– To visualize, specify, construct, and document your mapping, create a component diagram that contains components stereotyped as tables.

– Where possible, use tools to help you transform your logical design into a physical design

Page 17: Bab 11 component diagram 2010

Modeling a Physical Database

Page 18: Bab 11 component diagram 2010

Modeling Adaptable Systems

• To model an adaptable system– Consider the physical distribution of the components

that may migrate from node to node can specify the location of a component instance by marking it with a location tagged value, which you can then render in a component diagram (although, technically speaking, a diagram that contains only instances is an object diagram).

– If you want to model the actions that cause a component to migrate, create a corresponding interaction diagram that contains component instances.

Page 19: Bab 11 component diagram 2010

Modeling Adaptable Systems

Page 20: Bab 11 component diagram 2010

Forward and Reverse Engineering

• When you forward engineer a class or a collaboration, you really forward engineer to a component that represents the source code, binary library, or executable for that class or collaboration

• when you reverse engineer source code, binary libraries, or executables, you really reverse engineer to a component or set of components that, in turn, trace to classes or collaborations.

Page 21: Bab 11 component diagram 2010

Predefined Component Diagram Stereotypes

• File– Usually a source code file

• Binary / Library– Usually a compiled segment directly linkable into other

compilations• Executable

– Usually a directly executable module• Table

– Usually a database table• Page

– Usually a Web page• Document

– Usually a documentation file (as opposed to compilable code)

Page 22: Bab 11 component diagram 2010

Example of a UML Component Diagram

Page 23: Bab 11 component diagram 2010

Example of Source Code Dependencies

<<page>>home.html

<<file>>aProg.java

<<document>>aProg.doc

<<document>>anotherProg.doc

<<file>>anotherProg.java

Page 24: Bab 11 component diagram 2010

Runtime Component Example

<<library>>comms.dll

<<library>>graphics.dll

<<library>>dbgate.dll

<<executable>>viewer.exe

Page 25: Bab 11 component diagram 2010
Page 26: Bab 11 component diagram 2010

Component Diagram

• Shows an encapsulated class and its interfaces, ports, and internal structure consisting of nested components and connectors

• Addresses the static design implementation view of a system

Page 27: Bab 11 component diagram 2010

Component Diagram Example in UML 1.4

Page 28: Bab 11 component diagram 2010

Component Diagram Example in UML 2

Page 29: Bab 11 component diagram 2010

Copyright © 1997 by Rational Software Corporation

Course CourseOffering

Student Professor

contoh

Course.dll

People.dll

Course

User

Register.exeBilling.exe

BillingSystem

Page 30: Bab 11 component diagram 2010

NOTE :Component and Composite

Structure Diagrams

Page 31: Bab 11 component diagram 2010

Component and Composite Structure Diagrams

• A component diagram shows the internal parts, connectors, and ports that implement a component

• A composite structure diagram shows the internal structure of a class or a collaboration

• The difference between component and composite structure is small and we will treat them both as component diagrams

Page 32: Bab 11 component diagram 2010

Terms and Concepts

• An interface is a collection of operations that specify

a service that is provided by or requested from a

class or component

• A component is a replaceable part of a system that

conforms to and provides the realization of a set of

interfaces

• A port is a specific window into an encapsulated

component accepting messages to and from the

component conforming to specified interfaces

Page 33: Bab 11 component diagram 2010

Terms and Concepts (con’t)

• Internal structure is the implementation of a

component by means of a set of parts that are

connected together in a specific way

• A part is the specification of a role that composes

part of the implementation of a component.

– In an instance of the component, there is an instance

corresponding to the part

• A connector is a communication relationship between

two parts or ports within the context of a component

Page 34: Bab 11 component diagram 2010

Components

• A component is a replaceable part of a

system that conforms to and provides

the realization of a set of interfaces

• Graphically, a component is rendered

as a rectangle with a small two-pronged

icon in its upper right corner

Page 35: Bab 11 component diagram 2010

Components and Interfaces

• An interface is a collection of operations

that are used to specify a service of a

class or a component

• An interface that a component realizes

is called a provided interface

– An interface that the component provides

as a service to other components

Page 36: Bab 11 component diagram 2010

Components and Interfaces• An interface that a component uses is called

a required interface

– An interface that the component conforms to when requesting services from other components

• A given interface may be provided by one component and required by another

• A component that uses a given interface will function properly no matter what component

realizes that interface

Page 37: Bab 11 component diagram 2010

Components and Interfaces

Page 38: Bab 11 component diagram 2010

Binary Replaceability• The basic intent of every component-

based operating system facility is to

permit the assembly of systems from

binary replaceable parts

– Can create a system out of components

and then evolve that system by adding new

components and replacing old ones

Page 39: Bab 11 component diagram 2010

Characteristics of A Component

• It is replaceable

• It is part of a system

• It conforms to and provides the realization of a set

of interfaces

• Component diagrams can be used for both logical

and physical modeling

– Component diagrams are often used for physical

modeling of the software architectures of systems

Page 40: Bab 11 component diagram 2010

Organizing Components

• Can organize components by grouping

them in packages in the same manner

in which one organizes classes

• Can organize components by specifying

dependency, generalization, association

(including aggregation), and realization

relationship among them

Page 41: Bab 11 component diagram 2010

Ports• A port is an explicit window into an

encapsulated component• A port has identity

• Ports permit the interfaces of a component to be divided into discrete packets and used independently

• A port is shown as a small square straddling the border of a component– It represents a hole through the encapsulation

boundary of the component

Page 42: Bab 11 component diagram 2010

Ports (con’t)• Both provided and required interfaces may be

attached to a port

– A provided interface represents a service that can be requested through that port

– A required interface represents a service that the port needs to obtain from some other component

• Each port has a name so that it can be uniquely identified given the component and

the port name

• Ports are part of a component

Page 43: Bab 11 component diagram 2010

Ports

Page 44: Bab 11 component diagram 2010

Internal Structure• The internal structure of a component is

the parts that compose the implementation of the component together with the connections among them

• A part is a unit of the implementation of a component

– A part has a name and a type

Page 45: Bab 11 component diagram 2010

Parts within A Component

Page 46: Bab 11 component diagram 2010

Parts of the Same Type

Page 47: Bab 11 component diagram 2010

Connector• A wire between two ports is called a

connector• Show connectors in two ways

– If two components are wired explicitly, draw a line between them or their ports

– If two components are connected because they have compatible interfaces, use a ball-and-socket notation

• A delegation connector wires internal ports to external ports of the overall component

Page 48: Bab 11 component diagram 2010

Connectors

Page 49: Bab 11 component diagram 2010

Component Diagrams

• A component diagram shows an

encapsulated class and its interfaces,

ports, and internal structure consisting

of nested components and connectors

• Component diagrams address the static

design implementation view of a system

Page 50: Bab 11 component diagram 2010

Example of Component Diagram

Page 51: Bab 11 component diagram 2010