G64OOS: Object Oriented Systems • What is this module about?

• What is this module about?
G64OOS: Object Oriented Systems
• What is OOS?
Lecture 1: Introduction to Object Oriented Systems
Abdur Rakib
[email protected]
Mission Statement
 To learn what the object oriented
paradigm is, and when it is
beneficial to use.
 To learn how to use OOS principles
along the entire trajectory of
software development.
• Lecture Goals Outline
1.
Get to know organizational details of the course
2.
Acquaint yourself with the topics in G64OOS
3.
Learn how your knowledge uptake will be evaluated
4. Get an idea of how OOS might be used in real life
scenarios
5.
Learn some of the basic OOS terminology
 To learn Object Oriented
Programming (OOP) in C++.
Resources
• Module modalities
• Convenor: Abdur Rakib
Office BB72
• Venue: BA21 (Lectures are at 11-13.00 on Friday)
BB81 (Labs are at 9-11.00 on Friday)
• Evaluation: 60% Final Exam, 40% Course works (two)
• Prior knowledge: high-level programming (e.g., G54PRG)
 Website: http://kefzabr.jupiter.nottingham.edu.my/G64OOS/
 Moodle: https://moodle.nottingham.ac.uk/login/index.php
 Books:
•The C++ Programming Language, by Bjarne Stroustrup
•SAM’s Teach yourself C++ in 24 hours, by Liberty & Cadenhead
• UML Distilled, by Martin Fowler & Kendal Scott
•Object-Oriented Analysis and Design, by Grady Booch
 All labs and coursework will be in UML and C++
 Software:
•Visual Paradigm, free academic license
• Code::Blocks, free cross-platform IDE
1
Introduction
Introduction
 Your first day at work
•Develop the control software for a novel video tagging tool
•Project budget: MYR 50.000
•Project time: 6 month
•Produce software that is easy to maintain and extend
 How would you approach this project?
Introduction
•Your task requires an OO approach!
•Analysis
•Modelling
•Programming
Introduction
•Object-Oriented Programming
“Object-oriented programming is a method of implementation in
which programs are organized as cooperative collections of objects
...”
•Object-Oriented Design
“Object-oriented design is a method of design encompassing the
process of object- oriented decomposition ...” – using object and
classes to describe the system
•Object-Oriented Analysis
“Object-oriented analysis is a method of analysis that examines
requirements from the perspective of the classes and objects found in
the vocabulary of the problem domain”
Introduction
A Brief History of OOS
•Useful concepts:
Inheritance: reuse code of existing objects and/or establish a subtype
from an existing object
Encapsulation: restrictions on data access
Modularity: A set of related procedures with the data they manipulate is
often called a module.
“Modularity is the property of a system that has been
decomposed into a set of cohesive and loosely coupled modules”
Polymorphism: polymorphism means that some code or operations or
objects behave differently in different contexts
Abstraction: essential characteristics of an object
•Software development theory
• Procedural Paradigm
• Modular Paradigm
• Data Abstraction Paradigm
• Object Oriented Paradigm
•History of Object Oriented Programming languages
•S i m u l a
•C++
•Eiffel
•Java
2
C++ in perspective
C++ in perspective
•C++ vs. Java
•C++ vs. C
•C is a procedural/functional programming language
•C does not support OOP – no classes, no polymorphism
•Java runs on a virtual machine – inherently cross-platform
•VM means low-level system facilities and native system libraries are not
directly accessible
•Java has no unsigned type support
•You must declare functions before use
•Automatic garbage collection
•Slightly limited inheritance
•No (function) pointers
•No standalone functions
•More information:
•–
•–
Hands-On OOAD Example
 Analysis
•The User Story
•Use Case Diagrams
 Design
•Class Diagrams
http://www.dickbaldwin.com/java/Java008.htm
http://www.lrdev.com/lr/java/javacppdiffs.html
Hands-On OOAD Example
•Analysis: The User Story
•Stating the need
•Collecting and prioritising high-level features
•Should be written by project stakeholders and not the developers
•Keep it simple!
•State Machine Diagrams
•Sequence Diagrams
 Programming
Hands-On OOAD Example
 The User Story
Hands-On OOAD Example
•Analysis: Use Case Diagrams
•Develop a simulation software that allows to simulate customer/staff
•interactions in a grocery store
 Story: Customers come into a grocery store, pick up a few items, pay for
them, and leaves the grocery store
 Goals of simulation:
•Help to improve customer experience
•Optimize staffing
3
Hands-On OOAD Example

Hands-On OOAD Example
Use Case Diagrams
•UML diagram(s) + Documentation + Prototype Screen(s)
• Used to describe a set of user scenarios
•Captures system functionality as seen by the users
 Use Case Diagrams
•Develop a simulation software that allows to simulate customer/staff
•interactions in a grocery store
 User Story: Customers come into a grocery store, pick up a few items, pay
• Telling a story in a highly structured way
 Defining interactions between a role (known as an actor) and a
system, to achieve a goal
 Define actors (can be roles or systems), define who and what will
interact with the system
 Define UseCases (procedures by which an actor might use a system)
 Sometimes it is useful to sub-divide UseCases into lower level
activities
Hands-On OOAD Example
for them, and leaves the grocery store.
 Goals of simulation:
Help to improve customer experience
Optimize staffing
•–
–
 Your task: Create a Use Case
Hands-On OOAD Example
•Design: Class Diagrams
Hands-On OOAD Example
 Class Diagrams
Hands-On OOAD Example
• Your Task: Create the remaining Classes
•Show a set of classes, interfaces and collaborations, and their relationships
•Addresses static design view of a system
•Classes
 Blueprints (templates) for objects
 Contain data/information and perform operations
4
Hands-On OOAD Example
Hands-On OOAD Example
•Design: State Machine Diagrams
•Class Diagrams
Hands-On OOAD Example
•State Machine Diagrams
•Addresses the dynamic view of a system and is important in modelling
•the behaviour of an interface, class or collaboration
Hands-On OOAD Example
•Your Task: Create the remaining State
Machines
•Consist of states, transitions, events, and activities
Hands-On OOAD Example
•State Machine Diagrams
Hands-On OOAD Example
•Design: Sequence Diagrams
5
Hands-On OOAD Example
• Sequence Diagrams
• Your Task: Create the Sequence Diagram
– Shows potential
interactions consisting of a
set of objects and the
messages sent and
received by those objects
– Address the dynamic
behaviour of a system
with special emphasis on
the chronological ordering
of messages
– Consists of objects,
messages, object lifelines,
activation
G64OOS (2012)
Hands-On OOAD Example
31
G64OOS (2012)
From OOAD to OOP
Hands-On OOAD Example
• Sequence Diagram
32
• Programming
class Customer
{
// -- Members variables
float money;
std::list<item> shoppingList;
std::list<item> shoppingBasket;
class Clerk
{
// -- Member variables
bool availability;
// -- Member functions
bool isAvailable();
void setAvailability(bool b);
void serve();
void stock();
// -- Member functions
void shop();
void collectGroceries();
void checkOut();
void pay(float m);
}
};
G64OOS (2012)
33
G64OOS (2012)
From OOAD to OOP
34
Summary
• The OOS paradigm aims to design software by modelling problems in a
way that comes natural to humans, that is, by categorising the world
around us into objects that relate to and interact with each other.
• The result :)
• C++ was designed to implement such OOMs efficiently, while still giving
the programmer great power over the available resources (most notably
memory and processor cycles).
• UML is used to specify, visualise, modify, construct and document the
artefacts of an OO software-intensive system under development.
• Suggested Reading for this lecture:
Chapter 2, Object-Oriented Analysis and Design, by Grady Booch
G64OOS (2012)
35
G64OOS (2012)
36
6
Acknowledgements
Lecture slides used in this presentation
are adapted from the same module
taught in Nottingham, UK campus, by
Peer-Olaf Siebers and Michel Valstar
7