Download presentation
Presentation is loading. Please wait.
1
Object Oriented Software Development 2009-2010 Modelling information systems OOSAD Booklet Chapter 4 Lecture: Week 3 Brian Farrimond
2
2 Objectives At the end of this week you should: Be able to identify Classes and correctly represent them on a Class Diagram. Be able to identify attributes and distinguish them from Classes Be able to use StarUML to draw class- association diagrams
3
3 Testlet True or False 1. Associations show Generalization relationships 2. Associations are relationships between Objects 3. Associations are relationships between Classes 4. The Class-Association diagram shows messages paths. 5. The Class-Association diagram shows all the objects in a system. 6. The identity of an object is uniquely defined by the values of its attributes. 7. The state of an object is uniquely defined by the values of its attributes.
4
4 Testlet True or False 1. Associations show Generalization relationships NO 2. Associations are relationships between Objects NO 3. Associations are relationships between Classes YES 4. The Class-Association diagram shows messages paths. YES 5. The Class-Association diagram shows all the objects in a system NO 6. The identity of an object is uniquely defined by the values of its attributes. NO 7. The state of an object is uniquely defined by the values of its attributes. YES
5
5 A Class-Association Diagram
6
6 Identifying Classes..... A class can represent a real-world thing, (e.g. A Car) A role (e.g. A member) An Event / Interaction (e.g. A meeting)
7
7 Identifying Classes A good way to start is to underline nouns or noun-phrases in the problem statement (System requirement specification) Noun: “A word that refers to a person, place or thing” Noun-Phrase: A group of words that act like a noun. Eg a Dentist appointment
8
8 Exercise: identify potential classes A library contains publications, which are books or journals. A library member may borrow up to six items at any one time. Journals cannot be borrowed. The System must keep track of borrowers and Publications that they have borrowed. The library may hold several copies of any particular book. A copy is identified by a unique accession number
9
9 Exercise: identify potential classes A library contains publications, which are books or journals. A library member may borrow up to six items at any one time. Journals cannot be borrowed. The System must keep track of borrowers and Publications that they have borrowed. The library may hold several copies of any particular book. A copy is identified by a unique accession number
10
10 Potential Classes – which should we keep? LibraryBook JournalLibrary member ItemOne Time SystemBorrower PublicationCopy (of book) Accession Number
11
11 Rejecting candidates Redundancy Duplicate names for same thing. Names for the system itself, or outside the system Vague nouns – unclear of meaning Attributes of another class Meta-language Language about requirements etc
12
12 Key Question Does the Class Record Data (i.e. have any attributes? No data => No Class
13
13 Refined list of classes LibraryReject – system itself BookOk JournalOkLibrary memberOk ItemDuplicate name for Copy of Book One TimeVague SystemMeta languageBorrowerDuplicate (Member) PublicationPossibly superclass Copy (of book) Possible, but may be considered as instance of Book Accession Number Attribute of Book
14
14 Class Diagram.. assuming no Copy class Member Publication JournalBook Add Associations, Multiplicities and Generalisation s
15
15 Exercise: identify associations A library contains publications, which are books or journals. A library member may borrow up to six items at any one time. Journals cannot be borrowed. The System must keep track of borrowers and Publications that they have borrowed. The library may hold several copies of any particular book. A copy is identified by a unique accession number
16
16 Exercise: identify associations A library contains publications, which are books or journals. A library member may borrow up to six items at any one time. Journals cannot be borrowed. The System must keep track of borrowers and Publications that they have borrowed. The library may hold several copies of any particular book. A copy is identified by a unique accession number
17
17 Associations & Generalisations A Member can borrow up to six Books. A Book is borrowed by 1 Member Generalisations A Book is-a-kind-of Publication A Journal is-a-kind-of Publication
18
18 Class Diagram Member Publication JournalBook 10..6 borrows
19
19 Class Diagram.. assuming there is a Copy class Member Publication JournalBook Add Associations, Multiplicities and Generalisation s Copy
20
20 Class Diagram with Copy class Member Publication JournalBook 10..6 borrows Copy is a copy of 1 1..*
21
21 A Warning…… 1.Suppose a problem statement includes: "The Member makes a reservation for a Book". What are the classes? MemberBookReservation makes for
22
22 A Warning…… 1.However, Suppose it was phrased as: " A Member reserves a Book"? What are the classes? Do these mean the same thing? Member Book reserves
23
23 Member Book reserves MemberBookReservation makes for Which is correct?
24
24 Exercise: Identify the classes The Bank of Hope offers a number of types of account to its customers. Student Accounts have free overdrafts up to a limit that depends on their year of study, but do not pay interest. Current Accounts pay interest at 3%, but there are no free overdrafts. A Customer can hold any number of Current Accounts, but only those who are studying at University can have a Student account. No-one can have more than one Student Account. A Student Account can only be held by one person.
25
25 Exercise: Identify the classes The Bank of Hope offers a number of types of account to its customers. Student Accounts have free overdrafts up to a limit that depends on their year of study, but do not pay interest. Current Accounts pay interest at 3%, but there are no free overdrafts. A Customer can hold any number of Current Accounts, but only those who are studying at University can have a Student account. No-one can have more than one Student Account. A Student Account can only be held by one person.
26
26 Refined List: Account(Generalisation) Student Account Current Account Customer (Generalisation) Student
27
27
28
28 Summary Class Diagram models show system structure (Static model) Classes model Things, Events, roles Identify nouns as candidate Check if they record data
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.