Title: Multimedia
1Multimedia Website Design
- Object Orientation Concepts
2Introducing Object Orientation
- What youll learn in this lecture -
- Why UML is necessary
- How UML came to be
- Diagrams of UML
- Multi-diagram approach to modelling
3What is OO?
- OO is a way of thinking
- Applying real world concepts to the components
that go together to make software - The theory rests on software reuse writing a
piece of software that you can use again - The UML represents objects
4Why OO?
- Software Reuse use an object again. Share your
objects with other programmers - Communication much easier if you can talk in
real world examples - Breaks down complex software into manageable
chunks
5What is an Object?
- An object is an instance of a class
- An object represents a real world item, or a
component of one - e.g. A Computer is a class
- e.g. A hard drive is a class that has a
relationship with the computer class
6What is a class made up of?
- An class contains attributes and operations
- An attribute is a property of the class, which is
instantiated in the object - An operation is a function of the class, which
executes according to the objectsattributes
7Class Task 1
- Read the scenario which proposes swipe cards for
LSD. - Working on your own, identify all the important
nouns in the document which will become classes
in our design.
8OO Concepts
- OO is a way of thinking about software
development using concepts - Abstraction
- Inheritance
- Polymorphism
- Encapsulation
- Message Sending
- Associations
- Aggregation
9Abstraction
- An Abstraction is a representation of an object
from its real-world counterpart - Its attributes and operations do not have to
correspond to the exact item - e.g. A car object does not need to have a
startWindowWipers operation if you dont need to
call it
10Inheritance
- An object inherits all of its classes
attributes and operations - However, a class can also inherit from a parent
class - e.g. a car class inherits some of its
operations and attributes from its parent,
vehicle class - Therefore, if a car class inherits from a
vehicle class and so does a motorcycle class,
car and motorcycle will share the same
components of vehicle
Vehicle
startEngine()
Car
Motorcycle
startEngine()openBoot()
startEngine()useCentreStand()
11Polymorphism
- Sometimes an operation can have the same name in
many classes - e.g. You can turn on a light, a car, a kettle,
etc - It is important that the operation being called
belongs to the class you intended to use - If a parent class has an operation show then
its up to the developer to implement the correct
operation in their class
12Encapsulation
- Encapsulation is hiding away functionality that
the developer doesnt need to know how it works
in order to use it - The Black Box approach
- This way you can build complex applications
without having to know how it all works!
13Messages
- A Message is a piece of information that is sent
from one object to another - i.e. the joypad sends a message to the XBOX and
the XBOX object responds - We can queue messages to an object
14Associations
- An association is some form of a link that two or
more objects share - An association can be unidirectional going
one way, like a tv remote to the tv, or
bidirectional such as a console and a joypad
when the joypad rumbles
15Aggregation
- An aggregation is an a collection of objects that
work together - e.g. a car is an aggregate of an engine,
chassis, wheel, etc. - A more hardcore version of aggregation is
composition. The term is used when an
aggregation is useless without all of its
components.
16Intermission
17Practical OO
18Theory in practice
- What youll learn in this lecture -
- Class Visualisation
- Attributes
- Operations
- Responsibilities and Constraints
- Determining Classes
19Class Visualisation
- A class is a box containing the name of the
class. - If the class has two words describing it, join
them and take the first letters of each word and
uppercase them.
Saloon Car
SaloonCar
20CV Packages
- A UML construct (technique) known as the package,
plays a role in the name. - A package is a way of organising classes
together. - The package is represented by a tab on top of the
folder.
Vehicles
21CV Pathnames
- If the SaloonCar is part of a package called
Vehicles, you can give it the full name of
VehiclesSaloonCar. - The double colons separate the name of the
package from the name of the class.
Vehicles SaloonCar
22Attributes
- An Attribute is a property of the class.
- It describes the type of data an instance of the
class holds. - A single word attribute is written in lower case.
E.g. colour. Two word attributes are written in
camel case, except the first word. E.g.
brandName.
SaloonCar
colour brandName engineSize
23Attributes - Instantiation
- A named instance i.e. an object, can be written
out like the example opposite. Note the underline
in the title, and the single colon. - An attribute can also have defaults. They are
written similarly to the named instance, but with
a normal title.
MyCarSportsCar
colour Silver brandName Lotus engineSize
1796
SportsCar
colour brandName Lotus engineSize
24Operations
- An operation is something a class can do, or
something that can be done to the class. - Operation names are written in the same way as an
attribute, but with appended parenthesis.
SportsCar
colourbrandName engineSize
startEngine() removeHood() windWindow() turnOnRadi
o()
25Operations - Signature
- You can indicate additional information in
operations. - Included in the parenthesis are parameters, data
that the operation needs . - If a colon follows an operation, with a data type
following that, then that is the return value.
SportsCar
colourbrandName engineSize
startEngine( E Boolean) removeHood( H
String) windWindow( W Int) turnOnRadio( R
int) Boolean
26Class Task 2
- Again working on your own
- Look again at the list of classes you identified,
do you want to make any changes? - For each of the classes you identified, draw a
visual representation showing class name,
attributes and operations.
27Visualising make it easy!
- When dealing with many classes on a single page,
its ok to remove the attributes and operations
for clarity. - To highlight some components of the class, leave
them in, and signify others with three periods.
SportsCar
SportsCar
colour
startEngine( E Boolean)
28Visualising - Stereotypes
- You can use stereotypes to help understand the
class. - The stereotype is enclosed within guillemets
the angled brackets. - Stereotypes are very flexible constructs, you
can use them for anything that helps the user to
understand.
SportsCar
ltlt id gtgt serialNo ltlt model data
gtgt colourbrandName engineSize
startEngine( E Boolean) removeHood( H
String) windWindow( W Int) turnOnRadio( R
int) Boolean
29Responsibilities
- A classes Responsibility can be denoted with
another box underneath the class. - It shows what the class must do.
- A Constraint is a limitation of the attribute
or operation. - It is shown by a sentence in curly braces.
SportsCar
serialNo
startEngine( E Boolean)
can only do it with ignition on
ResponsibilityTo deliver its passengers to
another destination
30Notes
- A note can be added to any part of the class, or
the class itself. - The note icon has a dotted line which connects
the note to what the note is about.
A note
SportsCar
serialNo
startEngine
31Finding Classes
- Classes are the vocabulary of any area of
knowledge. - They are the nouns in any sentence.
- Attributes are the nouns describing nouns, and
operations, the verbs. - After you have highlighted each class, you can
ask the client what attributes they contain and
operations they perform.
32Intermission
33Relationships in the UML
34Relationships
- What youll learn in this section -
- Associations
- Multiplicity
- Qualified Associations
- Reflexive Associations
- Inheritance and Generalisation
- Dependencies
35Associations
- Relationships exist between classes.
- Mostly, a class has a relationship with multiple
classes - Each relationship can be identified by an arrowed
line with an explanation between classes - The class can signify a role by a name underneath
the relationship - Relationships can go both ways
Jumps from
Skydiver
Plane
Jumps from
Skydiver
Plane
passenger
vehicle
Jumps from
Skydiver
Plane
Gives a lift to
36Constraining associations
- A constraint can be placed on the relationship
- The Or relationship can be used to associate
classes by rules
Jumps from
Plane
Skydiver
Jumps from
Helicopter
37Association Classes
- An association class is a class that represents a
relationship and can have attributes and
operations - An instantiated class (an object) can represent
their relationships through links
Skydiver
Plane
Jumps from
Manifest
Ticket
Jumps from
Rob skydiver
Nomad Plane
38Multiplicity
- Multiplicity is very similar to ERDs
- Each class can have a number of other classes
associated with it - It represents how you can access the data held in
classes - You may use Qualifiers to determine a
particular key which you can use to identify the
class that owns another class
391
Skydiver
Plane
Jumps from
1
1
Skydiver
Chute
uses
1
1,2
Skydiver
Tickets
Can buy
1,2
Can have
Skydiver
Tickets
Skydiver_id
40Reflexive Associations
- Sometimes a class can have a relationship with
itself - For example, a pilot can be the pilot or an
occupant - This is represented by a line drawn to itself
Occupant
pilots
1
skydiver
0..23
41Inheritance Generalisation
- They both mean categorisations of classes into
general classes - A generalised or parent class holds attributes
and operations that all of their child classes
inherit - Discovering inheritance is an experience thing
use your knowledge of the real world to make it
happen - Abstract classes can never become objects, but
you can inherit from them for convenience
Person
Male
Female
Neutral
Skydiver
42Dependencies
- A dependency is a form of relationship when a
class need to use another object to perform its
function - It is represented by a dashed line into the other
class
Engine
43Aggregations
- An aggregation is relationship between classes,
that indicates that a class is made up from
multiple classes - For example, a car is made up from an engine,
seats, chassis, etc - A class that is part of an aggregation has a
diamond along its connecting line
44Car
1
1
1..5
Seat
Engine
1
Ignition System
Fuel System
45Aggregation Constraints
- A constraint of an aggregation is indicated by a
dashed line going between the two optional
components - In this case, a car can have a hardtop or a soft
top but not both
Car
1
1
1
or
Soft top
Hard top
46Composites
- A composite is a strong aggregation
- A black diamond represents that the relationship
must contain the composite classes
Kettle
1
1
1
Heating Element
Container
47Contexts
- A context puts classes together in a rational
way. For example, a skydiver has a parachute,
which contains a canopy and lines - There are two versions of context diagrams one
being a composite context diagram (a class that
owns all the other classes) and a system context
diagram (which shows where the context fits in
with the rest of the system)
48Kettle
Is located in the bottom of gt
1
Heating Element
Container
49Interfaces Realisations
- Sometimes, youll create a class that requires
some functionality of another class, but isnt
directly related to them - In this case, remove the functionality from both
and create an interface - An interface is a common set of functionality
that can be applied to any class - The relationship is called a realisation
50Email
ltlt Interface gtgtMessage
Email
Name Subject
Send() Delete()
51Visibility
- Visibility is how accessible components
(attributes operations) of the class are - A components visibility can be public (),
private (-) or protected () - A public component can be accessed by any other
component in the system, whereas a private
component is not accessible by anyone - A protected component can be accessed by any
component that sub classes the original
Email
Email Recipient -Sender
Send() Delete() updateProfile()
52Scope
- Scope is relevant to attributes and operations
and how they are accessed in the system - In instance scope, the component is available
to the class only - In classifier scope, the component is
available across all instances of the class.
Classifier scope components are underlined
53Class Task 3
- Working in groups, attempt to construct a full
class-diagram for the proposed system.