/
Class Diagrams Class diagram – basic syntax Class Diagrams Class diagram – basic syntax

Class Diagrams Class diagram – basic syntax - PowerPoint Presentation

dandy
dandy . @dandy
Follow
77 views
Uploaded On 2023-06-23

Class Diagrams Class diagram – basic syntax - PPT Presentation

Class name Methods Class name Attributes Methods Class name Class name Attributes Association name aggregation specialization This is a subclass comments Aggregate Component This is a ID: 1002000

association class balance account class association account balance integer classes diagram object string borrower methods number component aggregation book

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Class Diagrams Class diagram – basic s..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

1. Class Diagrams

2. Class diagram – basic syntaxClass name Methods Class nameAttributes Methods Class nameClass nameAttributes Association nameaggregationspecializationThis is a subclasscommentsAggregate ComponentThis is a superclass

3. Class Diagram - semanticsA class icon must have a class name. Optionally, it can have attributes and/or methods.Attributes and methods are strings and will not be validated by the modeling tools.Attributes can be specified by their names or by <name : type> pairs.Methods can be specified by their names or with partial signatures or with complete signatures.

4. Class Diagram – basic syntax (continued)Comments can be included in any diagram with a rectangle folded at right top cornerThe dotted line from the comment is important to indicate which portion of the diagram is explained by the comment Suggestion For verification purposes, when showing aggregation relationship, the aggregate (the one near the diamond edge) must include an attribute whose type is the component class

5. Details of a class iconAccount- Account number : Integer - Balance : Real- Overdraft : Boolean = true+ GetAccountNumber () : Integer# UpdateBalance (sign : Sign, amt : Integer)~ ReturnBalance () : RealChangeOverdraft ()+ public private# protected ~ visible within the packageInitial value

6. Another view of the same classAccountPrivate: Account number : Integer Balance : RealOverdraft : Boolean = truePublic:GetAccountNumber () : IntegerProtected:UpdateBalance (sign : Sign, amt : Integer)Package:ReturnBalance () : RealPrivate:ChangeOverdraft ()Initial value

7. An abstract classPolygon{abstract, author = Kasi, last modified = Oct 2002}<<constructor>>+ Polygon(List of Vertex vertices)<<query>>#area () : Real

8. ATM – class diagramAccount- Account# : Integer- UserID : Integer- Balance : Double+ getBalance() : double+ verifyUser (actnum, uid) : Boolean+ deposit (amt) + withdraw (amt)Accounts DatatableLogin Accounts Datatable- Accounts : Account[]- Accounts : Login Account[]+ addAccount (account)+ deleteAccount (acct#)+ searchAccount (acct#)+ updateAccount (acct#)+ addAccount (account)+ deleteAccount (uid)+ searchAccount (uid)+ updateAccount (uid)Login Account- UserID : Integer- Password : String + changePassword (str)uses11

9. ItemTitle : StringCallNumber : StringBookAuthor : StringYearOfPublication : IntegerPeriodicalVolume : StringIssue : StringYear : IntegerBorrowerID : StringBooksBorrowed : BorrowItem[]Fine : DoubleBorrowItemBorrowerID : StringDueDate : DateLibraryBooks : Book[]Loans : BorrowItem[]Periodicals : Periodical[]Users : Borrower[]addBook : (b : Book)addPeriodical (p : Periodical)searchBook (callno : String) : BooksearchPeriodical (callNo : String) : PeriodicaladdUser (u : Borrower)deleteUser (id : String)searchUser (id : String) : BorrowerloanItem (u : Borrower, b : Book)addBorrowItem (bi : BorrowItem)deleteBorrowItem (callNo : String)calculateFine()payFine (u : Borrower)

10. Association –syntaxUserAccount-Account number-Balance-Overdraft +Get accountID ()+Update balance()+Return balance()uses1nAssociation labelDirection of associationcardinalityManager customerUnary associationRole namesCorporate Account1n{xor}uses

11. Association - SemanticsEvery association is expected to be labeledUML does not require a name for an associationDirection of an association, cardinality, role name are all optionalFor unary associations, it is better to include role namesRepresentations of cardinality0, 1, * (zero or more), n..m (values in the range between n and m both inclusive)

12. Association – Semantics (continued)A constraint may be [optionally] placed between two associationsSee the example in the previous slide that asserts an Exclusive OR relationship between the associationsWhen a subclass specializes a superclass, it also inherits all associations between the superclass and other classesIn the previous example, the association “uses” between “User” and “Account” is also inherited by the pair “User” and “Corporate Account”

13. Association with qualifiersUserAccount-Account number-Balance-Overdraft +Get accountID ()+Update balance()+Return balance()uses1nCorporate AccountAccount numberQualifier Qualifier attribute

14. Association - QualifiersQualifiers can be attached to a “one-to-many” associationIt is rectangle attached to the “many” end of the associationA qualifier is a collection of variables whose values uniquely identify an instance at the “many” end of the associationIn the example, an account number uniquely identifies an account in a collection of accountsQualifier is part of the association

15. Association ClassUserAccountTransactionEmployeeJobSalary

16. Association Class - semanticsA piece of information that belongs to both classes in an association is put into a separate class called “association class”Association class is a dependent class that depends on the other two classes in the associationAn association class cannot exist independentlyAn object of an association class must refer to objects of the other two classes in the associationExample: A “Transaction” object depends on a “User” object and on an “Account” object.

17. Shared AggregationAn aggregation relationship in which the component can be shared by classes/objects outside the aggregationTeamPersonFamilyPerson object is shared by both Team and Family objectsShared aggregation is indicated by a hallow diamondCaution: Changes made to a component object will affect all the aggregates that include the component.

18. Composite AggregationAn aggregation relationship in which the component is an exclusive part of the aggregate; hence, not shared.Air PlaneWingEngine1212Composite aggregation is indicated by a filled diamond

19. Advanced SpecializationPersonBoyGirlSwimmerRunnerGender{complete, disjoint}Sports activity{incomplete, overlapping}These optional domain words make the relationships easier to understand.

20. Exercise 1Extend the library class diagram to include the following:Borrowers can now reserve books. No periodical can be reserved.A book can be reserved only when a borrower wants to borrow that book but it is loaned to another borrower  need some status variable for books.

21. Exercise 2Redesign the classes in Exercise 1 so that the classes “Borrow Item” and “Reservation” are now designed as Association classes.