13.07.2015 Views

Object-Oriented Software Development with UML - UNU-IIST ...

Object-Oriented Software Development with UML - UNU-IIST ...

Object-Oriented Software Development with UML - UNU-IIST ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Creating Collaboration Diagrams 103ExampleIn the POST application, consider the part of the conceptual model shown in Figure 7.20.SaledatetimeContains1..*SalesLineItemquantity*Described-byProductSpecificationdescriptionpriceupcFigure 7.20: Partial conceptual modelSince ¿+ÀÁ[Æ a contains (in fact, aggregates) ¿+À§Á†ÆDÂ;à ÄLÅ+ÆSÇWÈXÆDÉ many objects, the Creator pattern ¿+ÀÁ[Æsuggestsis a good candidate to be responsible for ¿+ÀÁ[ÆWÂ:à ÄLÅ+Æ9ÇWÈXÆÉ creating objects. This leads to a design of objectinteractions in a collaboration diagram, as shown in Figure 7.21.makeLineItem(quantity)1:create(quantity):SaledatetimeSale:SalesLineItemmakeLineItem()total()Figure 7.21: Create a SalesLineItemThe assignment of this responsibility requires that aɈÀBØ¥Æ9Ã]Ä^Å+ÆSÇWÈXÆDÉ method be defined in¿+À§Á†Æ . In general,a method has to be defined in a class to fulfill each responsibility assigned to that class.Sometimes a creator is found by looking for the class that has the initialising data that will be passed induring the creation of an object. This is actually an example of the Expert pattern. For example, assumethat a Î À§ÍBÉdÆÅsÈ instance needs to be initialised, when created, <strong>with</strong> the ¿+ÀÁ[Æ total. Since ¿+ÀÁ[Æ knows thetotal,¿-ÀÁ†Æ is a candidate creator of the Î ÀÍÉdÆDÅ_È object.Low CouplingCoupling is a measure of how strongly one class is connected to, has knowledge of, or relies upon otherclasses. A class <strong>with</strong> low (or weak) coupling is not dependent on too many other classes.A class <strong>with</strong> high (or strong) coupling relies upon many other classes. Such classes are undesirable; theysuffer from the following problems:Report No. 259, July 2002<strong>UNU</strong>/<strong>IIST</strong>, P.O. Box 3058, Macau

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!