Presentation is loading. Please wait.

Presentation is loading. Please wait.

Modeling Classes with UML

Similar presentations


Presentation on theme: "Modeling Classes with UML"— Presentation transcript:

1 Modeling Classes with UML
CSCE 121 J. Michael Moore

2 Modeling Objects Objects used in many programming languages
Ideally is independent of the programming language Language Agnostic The focus should be what instead of how. There are many options, so leave the implementation details to the coder. Think about what data means or a mathematical definition instead of focusing on the datatypes available in a language. Dollars instead of double. Integer instead of int. Floating point instead of double or float. Letters instead of char. List instead of vector. (You can say array if you mean it in the mathematical sense.)

3 Class Start thinking about what you want to represent Characteristics
Candidates for attributes Actions (by / to object) Candidates for methods

4 UML Unified Modeling Language Used primarily for Software Engineering
Language Agnostic Many types of UML diagrams used for design and modeling Class diagrams Structure diagrams Sequence diagrams Activity diagrams State machine diagrams

5 Methods / Member Functions
UML Class Diagram Model Classes (language agnostic of course!) 3 parts Include what we need, not everything we can think of. Programs can help Visio: Free on Dreamspark (Collaborative) Any program you can draw boxes and type text! Name Attributes / Data Members Methods / Member Functions

6 Attributes Book <AttributeName>: <AttributeType>
Attribute Type is optional Start with lowercase Type after colon Types are NOT C++ datatypes! Should be descriptive of what it is, not how it will be stored in C++ Ex: Dollars instead of double Can include this type of information for methods too Book title author: String due: Date checkedOutBy: Patron

7 Methods <MethodName>(<parameter>: <AttributeType>):<ReturnType> Start with lowercase Book title: String author: String due: Date checkOut(patron: Patron, due: Date) getAuthor(): String setTitle(title: String)

8 Visibility Book Public: prepend name with ‘+’
Private: prepend name with ‘-’ Book -title -author: String -due: Date +checkOut(patron: Patron, due: Date) +getAuthor(): String +setTitle(title: String)

9 Relationships Show relationship between classes Association Person
Has a Aggregation Has an aggregation (grouping) of Composition Like has a, but is a part of More later… Person Umbrella Class Roster Student Person Arm

10 Try to match relation to attribute/method or to the name.
Relationships Library -name: String -collection: Book Book +addBook(book: Book) -title: String -author: String -due: Date -checkOutBy: Patron Patron +checkOut(patron: Patron, due: Date) +getAuthor(): String +setTitle(title: String) Try to match relation to attribute/method or to the name. -name: String


Download ppt "Modeling Classes with UML"

Similar presentations


Ads by Google