Oct 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. Ch 18
Oct Ron McFadyen Figure 18.1 Visibility from Register to Product Catalogue is required due to the collaboration diagram Visibility
Oct 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
Oct Ron McFadyen Figure 18.2 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.
Oct Ron McFadyen Figure 18.3 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
Oct Ron McFadyen Figure 18.4 from Parameter to Attribute visibility
Oct Ron McFadyen Figure 18.5 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.
Oct Ron McFadyen Figure 18.4 showing visibility in the UML
Oct Ron McFadyen Preview Figure DCD with dependency relationships indicating non-attribute visibility
Oct Ron McFadyen Preview Figure 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