Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2009AXS-3913 Ron McFadyen Visibility Visibility: the ability of one object to see or have a reference to another object. e.g. When a register object.

Similar presentations


Presentation on theme: "Fall 2009AXS-3913 Ron McFadyen Visibility Visibility: the ability of one object to see or have a reference to another object. e.g. When a register object."— Presentation transcript:

1 Fall 2009AXS-3913 Ron McFadyen Visibility Visibility: the ability of one object to see or have a reference to another object. e.g. When a register object sends a message to a sale object, the register must have visibility to the sale. enterItem() :Register:Sale 2:makeLineItem() Register has to know about sale in order to send this message. The sale must be visible to the register.

2 Fall 2009AXS-3913 Ron McFadyen Visibility from Register to Product Catalogue is required due to the collaboration diagram Visibility : Register enterItem (itemID, quantity) : ProductCatalog spec := getProductDesc( itemID ) { public void enterItem( itemID, qty ) {... spec = catalog. getProductDesc(itemID)... } } class Register {... private ProductCatalog catalog;... }

3 Fall 2009AXS-3913 Ron McFadyen Visibility Visibility from A to B can occur in four ways: Attribute B is an attribute of A Parameter B is a parameter of a method of A Local B is a non-parameter local object in a method of A Global B is globally visible

4 Fall 2009AXS-3913 Ron McFadyen Attribute Visibility Register has an attribute that holds the reference to the catalog, and so register has attribute visibility to the Product Catalog. This is very common. : Register enterItem (itemID, quantity) : ProductCatalog desc := getProductDesc( itemID ) { public void enterItem(itemID, qty) {... desc = catalog.getProductDesc(itemID)... } } class Register {... private ProductCatalog catalog;... }

5 Fall 2009AXS-3913 Ron McFadyen Parameter Visibility In our collaboration, register asks the product catalog to find a specific product specification. The catalog returns the product specification to the register, and register passes that on the sale. Sale will just pass that product specification on to the sales line item, and so the sale only has parameter visibility to the product specification

6 Fall 2009AXS-3913 Ron McFadyen from Parameter to Attribute visibility

7 Fall 2009AXS-3913 Ron McFadyen Local Visibility The enterItem method of Register has an attribute that will hold a product specification. When the method ends, the attribute value is lost. Visibility here is temporary – while the method executes. The visibility is local to the method. : Register enterItem (itemID, quantity) : ProductCatalog spec := getSpecification( itemID ) { enterItem(id, qty) {... // local visibility via assignment of returning object ProductSpecification spec = catalog.getSpecification(id);... } }

8 Fall 2009AXS-3913 Ron McFadyen showing visibility in the UML

9 Fall 2009AXS-3913 Ron McFadyen DCD with dependency relationships indicating non-attribute visibility

10 Fall 2009AXS-3913 Ron McFadyen DCD with dependency relationships indicating non-attribute visibility Dependency of Sale on Product Specification is shown with a dashed directed line. Sale has parameter visibility to Product Specification Dependency of Register on Product Specification is shown with a dashed directed line. Register has local visibility to Product Specification – register’s enterItem method gets a reference to a product specification and passes that on to the sale Attribute Dependencies are shown with the solid directed lines


Download ppt "Fall 2009AXS-3913 Ron McFadyen Visibility Visibility: the ability of one object to see or have a reference to another object. e.g. When a register object."

Similar presentations


Ads by Google