object oriented software development 2009-2010 modelling business objects oosad booklet chapter 4...

23
Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

Post on 22-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

Object Oriented Software

Development2009-2010

Modelling business objectsOOSAD Booklet Chapter 4

Lecture: Week 4Brian Farrimond

Page 2: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

2

Session Aims Representing attributes and operations in

class association diagrams Drawing class association diagrams

derived from business forms

Page 3: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

3

Attributes and operations As we gather requirements we find

out: what information each class of object

needs to record in the form of attributes what the system is supposed to do (we

initially record this in use case diagrams) it is the classes that will be required to carry

out these tasks we need to identify the operations that they

will need to perform to achieve this

Page 4: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

4

Attributes and operations in UML The UML class symbol is a box which

is divided into three sections class name class attributes class operations (aka methods)

Demo in StarUML

Page 5: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

5

Operations issues in UML All attributes should have:

setter operations to enable other objects to modify attribute values

getter operations that enable other objects to discover those values

Generally we can omit these from UML diagrams since they can be assumed

Page 6: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

6

Operations issues in UML Associations do not require

duplicated attributes in UML e.g. do not add a orders attribute to a

Customer class - the association line speaks for itself – avoid duplication

Bad!!

This does the job of modelling what is

going on

Page 7: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

7

Operations issues in UML Associations do not require

duplicated attributes in UML e.g. do not add a orders attribute to a

Customer class - the association line speaks for itself – avoid duplication

Good!Duplication

removed

Page 8: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

8

Modelling business forms

Page 9: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

9

Chapter 4 example

Typical order form

Page 10: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

10

Chapter 4 example

First attempt at a class diagram

Page 11: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

11

Chapter 4 example

First attempt at a class diagram

Problem with duplication of customer data over a number of his orders

Page 12: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

12

Chapter 4 example

Second attempt at a class diagram

Separate class to hold Customer details

Page 13: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

13

Chapter 4 example

Now we consider the array.

Neater to extract a class containing the details of each item ordered.

In Java, objects of this class might be held in an ArrayList

Page 14: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

14

Chapter 4 example

Now we consider the array.

Neater to extract a class containing the details of each item ordered.

In C++, objects of this class would be held in a vector

Page 15: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

15

Chapter 4 example

The new class describes a line on the original order form.

Convention is to name it OrderLine.

Page 16: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

16

Chapter 4 example

What would the equivalent class name be for a line on an Invoice?

The new class describes a line on the original order form.

Convention is to name it OrderLine.

Page 17: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

17

Chapter 4 example

The new OrderLine class duplicates information about the items being ordered.

Page 18: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

18

Chapter 4 example

We can remove this duplication by adding a final class.

Page 19: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

19

Chapter 4 example

We can remove this duplication by adding a final class.

Page 20: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

20

Exercise 4.7 (page 71)

Page 21: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

21

Create a class association diagram for this card

Page 22: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

22

Create a class association diagram for this card

Page 23: Object Oriented Software Development 2009-2010 Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond

23

Create a class association diagram for these forms

Top Grub Order form

Top Grub Invoice form

…. from Database Technology Course.