Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unified Modeling Language User Guide Section 2—Basic Structural Modeling Chapter 4—Classes.

Similar presentations


Presentation on theme: "Unified Modeling Language User Guide Section 2—Basic Structural Modeling Chapter 4—Classes."— Presentation transcript:

1 Unified Modeling Language User Guide Section 2—Basic Structural Modeling Chapter 4—Classes

2 Sung KimCS6359Slide 2 Overview Classes –Attributes –Operations –Responsibilities Modeling the vocabulary of a system. Modeling the distribution of responsibilities. Modeling non-software “things”. Modeling primitive types. Modeling quality abstractions.

3 Sung KimCS6359Slide 3 Classes Description of a set of objects that share the same attributes, operations, relationships, and semantics. Window origin size open() close() name attributes operations

4 Sung KimCS6359Slide 4 Names Distinguishing identity. Textual string. Simple name. Prefixed by package name to generate path name. Customer Account Temperature Sensor Circuit Java::awt::Rectangle Simple names path name

5 Sung KimCS6359Slide 5 Name Rules Consists of letters, numbers, and certain punctuation marks. Short noun phrases drawn from vocabulary of the domain. First letter of every word capitalized. TemperatureSensor BrokerageAccount

6 Sung KimCS6359Slide 6 Attributes Named property of a class. Describes a range of values that an instance of the property may hold. Short noun representing property of its enclosing class. First letter of every word capitalized except the first. birthDate userAccount

7 Sung KimCS6359Slide 7 Attributes (cont’d) attributes height : Float width : Float isStudent : Boolean = false origin size You can further specify an attribute by stating its class and possibly a default initial value

8 Sung KimCS6359Slide 8 Operations Abstraction of something that can be done to an object. Shared by every object of the same class. May cause object to change state. Short verb representing behavior of representing class. First letter of every word capitalized except the first. addUser() isEmpty()

9 Sung KimCS6359Slide 9 Operations (cont’d) operations reset() setAlarm( t : Temperature ) value() : Temperature add() move() You can specify an operation by stating its signature, covering the name, type and default value of all parameters and a return type

10 Sung KimCS6359Slide 10 Organizing Only a subset of attributes and operations are typically relevant to any one view. Elide a class; hide non-relevant information. Use stereotypes to categorize. Use ellipsis to specify additional attributes or operations > new() new( p : Policy ) > process( o : Order ) … > isSuspect( o : Order )

11 Sung KimCS6359Slide 11 Responsibilities Contract or obligation of a class. Carried out by attributes and operations. Techniques –CRC cards (Class-Responsibility- Collaborator); Kent Beck and Ward Cunningham; ’89 –Use case based analysis.

12 Sung KimCS6359Slide 12 Responsibilities (cont’d) Free-form text; one phrase per responsibility. Responsibilities -- determine the risk of a customer order -- handle customer-specific criteria for fraud FraudAgent responsibilities

13 Sung KimCS6359Slide 13 Modeling Techniques Vocabulary. Distribution of responsibilities. Non-software things. Primitive types.

14 Sung KimCS6359Slide 14 Modeling Vocabulary Things used to describe the problem or solution. Found through CRC cards and/or use case analysis. Identify responsibilities for each abstraction. Provide attributes and operations needed to carry out responsibilities.

15 Sung KimCS6359Slide 15 Modeling Distribution of Responsibilities Identify a set of classes that work together to carry out some behavior. Identify responsibilities for each class. Split classes with too much responsibility. Collapse classes with trivial responsibility. No class should do too little or too much.

16 Sung KimCS6359Slide 16 Modeling Non-software Things Model the thing as a class. Use stereotypes to give a distinctive cue. Consider nodes to model hardware. Use a unique icon.

17 Sung KimCS6359Slide 17 Modeling Primitive Types Model as a type using a class notation. Use stereotypes as necessary. Use constraints to represent valid values. > Boolean false true > Int { value range –2**31 to +2**31-1 }

18 Sung KimCS6359Slide 18 Hints & Tips Well-structured class –Provides a crisp abstraction drawn from vocabulary of problem or solution. –Embodies small, well-defined set of responsibilities. –Provides clear separation of the abstractions specification and implementation. –Understandable and simple. –Extensible and adaptable.

19 Sung KimCS6359Slide 19 Hints & Tips (cont’d) Drawing a UML class –Show only properties that are important in a specific context. –Organize long lists of attributes and operations by grouping. –Show related classes in the same diagrams.

20 Sung KimCS6359Slide 20 Summary Classes –Name. –Attributes. –Operations. –Responsibilities. Modeling techniques. –Vocabulary. –Responsibilities. –Non-software things. –Primitive types.


Download ppt "Unified Modeling Language User Guide Section 2—Basic Structural Modeling Chapter 4—Classes."

Similar presentations


Ads by Google