1 / 21

UML Class Diagram

UML Class Diagram. and a little about Object Diagrams. Class. Association. Business processes (in Activity Diagram). Communication between people (in Sequence Diagram. Business concepts (in Class Diagram). Use case. Activity Diagram. Sequens Diagram. Information Model

buentello
Download Presentation

UML Class Diagram

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UML Class Diagram and a little about Object Diagrams Class Association

  2. Business processes (in Activity Diagram) Communication between people(in Sequence Diagram Business concepts (in Class Diagram) Use case Activity Diagram Sequens Diagram Information Model (in Class Diagram) The reality and UML-models The reality UML-models

  3. Student Course personalnr name email courseID courseName registerForCourse() Class Diagrams – central in UML TheClassDiagramsarethemajority–havealmostbecomesynonymouswithUML. ClassDiagramsdescribesClassesinadomainorinasystem,andstaticassociationsbetweentheclasses. ClassDiagramsalsoshowstheattributesandoperationsoftheclasses. • Note that following words have been used as synonymes: • type och class, • relation och association, • structural och static. • In UML-context we should use the concepts marked in bold letters.

  4. Classes – UML-notation • The UML-notation for a class is a rectangle with (normally) three sections or compartments. • the compartment at the top contains the name of the class in bold letters and a capital first letter. • the compartment in the middle contains the names of the attributes in the class. • the compartment at the bottom contains the names of the operations in the class. Student Note the way to write the names of the attributes and operations – yet a convention and no formal rules: - begins with a small letter, a capital letter can be placed in the middle if it consists of several words. - name of the class and –names of the attributes are written as substantives or substantive phrases, names of classes begin with a capital letter. - operations are written as verbs, also note the parentheses after the operation name. personalnr name email registerForCourse()

  5. Student Student Student personalnr name email personalnr name email registerForCourse() requestIncreasedAccount() Classes – variants of notations Class name Operations Attributes

  6. Student personalnr name email registerForCourse() requestIncreasedAccount() Classes – objects, attributes & methods Objects: Studentscanhavealotofsimilarities,forexamplee-mail,andtheycanregisterforcourses. WecollectsimilaritiesandcreatetheclassStudent.EverystudentisnowanobjectoftheclassStudent. AllStudentobjectshaveavalueontheattributesandareabletoperformthemethods. Attributes:are used to describe static characteristics within a class. Are given values in their objects. Operations:are spoken about at class level when to represent the dynamic behaviors of the objects. Operations are called methods at the object level.

  7. Class Diagram and Object Diagram Class Object (instance) Object (instance) annaSvan:Student nilsHall:Student Student personalnr = ”770102-XXXX” name = ”Anna Cecilia Svan” address = ”Ekvägen 10” email = ”sva@dsv.su.se” personalnr name address email personalnr = ”850302-XXXX” name = ”Nils Erik Hall” address = ”Rågstigen 3” email = ”hal@dsv.su.se” Class Diagram Object Diagram Often called Instance Diagram. Increased notation för naming. Attributes gets values. All associationes from the Clas Diagram follows to the objects. Can be seen as a snapshot of one or more objects at a certain moment. Why? The values of the attributes can be changed during the lifecycle of the objects.

  8. Attributes & associations are properties Properties Associations Student Registration Course personalnr name email registrationID date courseID courseName Attributes Properties • Properties (characteristics) • is UML’s umbrella term for the attributes and associations of classes. • models the static (structural) characteristics of classes.

  9. Properties have multiplicity Student Registration Course 1..1 0..* 0..* 1..1 personalnr name email [1..1] registrationID date [1..1] [1..1] courseID courseName [1..1] [1..1] [0..1] [1..*] Themultiplicityforaproperty(attributeorassociation)indicateshowmanydifferentobjects(orvalues)thatareabletofulfiltheproperty. Multiplicityforassociationsisstatedateachassoiciatedclass. Thecompletewaytowritemultiplicity,isthat: -thesmallestnumberisstatedfirst, -thelargestnumberisstatedlast, -twodotsarewrittenbetweenthenumbers.

  10. Multiplicity – usual combinations Course Student Registration 0..* 1..1 0..* 1..1 personalnr name email [1..1] registrationID date [1..1] [1..1] courseID courseName [1..1] [1..1] [0..1] [1..*] 1..1Minimum1andmaximum1.Example:Astudenthasone,andonlyone,valueattheattributepersonalnr. 1..*Minimum1andaninfiniteuppernumber.Example:Astudentisalwaysgivenonee-mailaddress,butcanhavemanymoree-mails. 0..*0isvalidandaninfiniteuppernumber.Example:Astudentdoesnothavetoberegisteredonacourse,butcanberegisteredonmanycourses. 0..10isvalidandmaximum1.Example:Acoursedoesnotneedtohavebeengivenanameandcanpossiblyhaveonename.

  11. Multiplicity for associations Student Registration Course 0..* 1..1 0..* 1..1 personalnr name email registrationID date courseID courseName multiplicitydescribeshowmanydifferentobjectsthatcanbepartofanassociationbetweentwoclasses. Exemple: AStudentobjectisassociatedtozero-to-manyRegistrations. ARegistrationobjectisassociatedtoone-to-one,i.e.exactlyone,Student.

  12. More about multiplicity for associations Registration Student Course 1..1 0..* 0..* 1..1 anna:Student oop:Course 9:Registration nils:Student 2:Registration oos:Course 6:Registration tove:Student jök:Course

  13. Multiplicity of associations with Venn-diagram Student Registration Course 9 oop Anna 2 oos Nils 6 jök Tove

  14. Notes • Notes is comments in UML-diagrams. • Not connected to any special modelling element • If notes is about a special modelling element it is connected to the element with a broken line. Note that the line ends with a small unfilled circle. • Notes can also be used to state constraints for the modelling element. The constraints then have to be written within curly braces. Constraints can also be written in text or more formally. Includes University students, but not secondary school students. { Only students living at IP } Student

  15. Anställd + companynr: Integer [1..1] = 4222 {readOnly} Attribute - notation visibility name type multiplicity = default value {property} The only mandatory part in the notation of the attribute. The data typeof the value. Limits which type of values the attributes can have. Multiplicity Perhaps furtherproperties of the attribute. Automaticly assignedwhen an object is created. There are publik (+), privat (-), protected (#) visibility, and packet visibility (~).

  16. Employee + companynr: Integer [1..1] = 4222 {readOnly} + getNamn (employeenr:Integer): String Operationes - notation visibility name (parameter list) : return type {property} The only mandatory part in the notation of the operation. List of the parameters used by the operation. It can be input (in), output (out), or both (inout). The data type of the returnedvalue. Perhaps furtherproperties of the operation. There are publik (+), privat (-), protected (#) visibility, and packet visibility (~).

  17. UML-concept feature Features Static features Dynamic features properties Operations Attribute Associations

  18. To name associations Threewaystonameassociations: 1)withaverbateachclass. Teacher Student 0..* is supervised employeenr [1..1]] studregnr [1..1] is supervising 1..*

  19. To name associations Three ways to name associations:2) Only one verb at the association line . Teacher Student 0..* supervise employeenr [1..1] studregnr [1..1] 1..1

  20. To name associations Three ways to name associations: 3) With a substantive at each class. Teacher supervisor Student 0..* thesiswriter employeenr [1..1] studregnr [1..1] 1..*

  21. Class Diagram – a summary Classes Attributes Registration Student Associations personalnr name email [1..1] registrationID date [1..1] [1..1] [1..1] 1..1 0..* [1..*] Operations registerForCourse() listRegistrations() Multiplicity Includes University students, but not secondary school students. . Notes annaSvan: Student personalnr = ”770102-XXXX” name = ”Anna Cecilia Svan” email = ”sva@dsv.su.se” Objects registerForCourse()

More Related