You are on page 1of 33

Introduction to OO Concepts

Topic & Structure of the lesson


Introduction to OO Concepts
Introduction
Object-oriented concepts

Object
Class
Class Relationships
Generalization
Message
Encapsulation
Inheritance

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 2 (of 24)

Learning Outcomes
By the end of this lecture, YOU should
be able to :
Demonstrate and apply the key techniques of
analysis and design for the chosen
methodology
Appreciate the use of an analytical framework
for the analysis and design process
Document each stage of analysis and design
to the appropriate standards
CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 3 (of 24)

Key Terms you must be able to use


If you have mastered this topic, you
should be able to use the following terms
correctly in your assignments and exams:

Generalization
Message
Encapsulation
Inheritance

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 4 (of 24)

Introduction
OO Analysis
describes information systems by identifying
things called objects
popular approach
end model = object model represents
information systems in terms of objects and
object-oriented concepts

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 5 (of 24)

Current issues
Problems faced now:
Systems have grown larger
More complex
Not the only solution
Software crisis is worst today shorter time frame to create softwares

Changed interface
GUI preferred 4GL
CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Promises of OO
A new approach
Created to produce software that is more:
Maintainable
Testable
Reusable
Ability to cope with large, complex systems

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Conclusion to need of OO
Hence, the requirement for a better
approach was felt: Why?
To reduce development time
Create more robust (tough) systems
Autonomous (independent)systems
Maintainable systems
Testable systems

Thus, the OO approach was introduced


which was based upon OO concepts
CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

OO Concepts - Object
Objects
Model real-world objects in application
domain
Entities, objects or things
Forms the subject matter of the system
Eg. In a mail order system, the objects are
customers, orders, products
Eg. In a library system, the objects are members,
books, loans, reservations
Eg. In a restourant system, the objects are
customers, tables, reservations, cancellations
CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

OO Concepts - Object
Objects are features of the problem domain.
Types of objects:
a. Physical things- customers, products, members,
books
b. Conceptual things orders, loans, reservations,
cancellations
c. Organisational things companies, departments
d. Computer implementation features eg: GUI

Have attributes - characteristics


Have behavior eg: change address,
can start, stop, move
CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

car

OO Concepts - Object
Object
computer representation of real-world thing /
event
described by its:
Attributes characteristics that describe object
Methods tasks / functions

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 6 (of 24)

OO Concepts - Object
In UML, an object diagram is as shown
below: a software object
Jemina: Car
Fuel: 6.4 litres
Speed: 32kph
Temperature:
cool

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

OO Concepts - Class
Class-Defines an object
Specify the attributes and operations for
each instance of an object
Instance means a record.
A class shows a general representation
(variables and operations) of the object
diagram, not an instance.

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Object-oriented concepts
Class
category of similar objects
template for all objects of that class

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 7 (of 24)

OO Concepts - Class
Eg. Of a representation of a class diagram
in UML
Car
fuel
speed
temperature

stop()
start()
reverse()
move()
CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

OO Concepts - Class
association -- a relationship between instances
of the two classes. In a diagram, an association
is a link connecting two classes.
aggregation -- an association in which one class
belongs to a collection. An aggregation has a
diamond end pointing to the part containing the
whole.

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

OO Concepts - Class
generalization -- an inheritance link indicating one class
is a superclass of the other. A generalization has a
triangle pointing to the superclass.
An association has two ends. An end may have a role
name to clarify the nature of the association.
A navigability arrow on an association shows which
direction the association can be traversed or queried.

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

OO Concepts - Class
multiplicity of an association end is the number of
possible instances of the class associated with a single
instance of the other end. Multiplicities are single
numbers or ranges of numbers.
Multiplicities

Meaning

0 ... 1
n ... m
0 ... * or *

Zero or one instance


indicates n to m instances
no limit on the number of
instances (including none)

1
1 ... *

exactly one instance


at least one instance

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

OO Concepts - Attribute
It is the data items that defines a class.
Eg. name, address, telno, gender for the
class customer.
Each instance of the object has the same
number of attributes, but each instance
may have different values, eg: each
customer can have a different name.

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

OO Concepts - Operation

It is the equivalent of a function/procedure


Is always defined as part of a class
It combines to define class behavior
Achieves the responsibilities of a class
Eg:

class customer maintains data about customers;


class order maintains list of outstanding orders;
class supplier maintains list of suppliers
class product maintains list of products

Operation is the procedure of how to do it


CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

OO Concepts - Method
Refers to procedures that form part of a
class structure
Executed when a request is received
Operations are called methods during
code implementation, i.e. the code that is
executed during a request.

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

OO Concepts - Message
Objects interacting with one another requesting
for particular services.
It involves:
client / sender initiating object, makes/initiates request
server / receiver receiving object, executes request

Differences in the two approaches


Functional/structured approach data passes between
processing units (functions/procedures);
OO approach messages passed between objects

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Object-oriented concepts

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 14 (of 24)

OO concepts- Encapsulation
Encapsulation
packaging data and operations into an object
provides three software desirable software
properties:
Purpose:
Proper Modularity- Models real-world objects ,
easy to understand
Data Abstraction- Clients only need to know
information provided by the public interface
Data Hiding- Data encapsulated within an object
and only be accessed by that objects operations
CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 15 (of 24)

Object-oriented concepts
Inheritance
a mechanism which allows new classes to be
defined in terms of existing classes
new class inherits / includes the features
(operations and attributes) of the class it is
created from

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 16 (of 24)

OO Concepts - Inheritance
The child class:

Inherits characteristics of parent class


Can add features of its own to reflect its uniqueness
Can change and suppress inherited features
Has IS-A relationship with parent class
Eg. Car is a kind of vehicle; labrador is a kind of dog;

Indicated by a line between the classes and a


triangle pointing towards the parent class.
Typically, only required to show specialised features
in the specialised class
CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

OO Concepts - Inheritance
Inheritance

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 17 (of 24)

Object-oriented concepts
Polymorphism
the ability to define program entities that take
more than one form
allows a single message to be interpreted
differently by different objects

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 18 (of 24)

Object-oriented concepts
Polymorphism

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 19 (of 24)

Follow-up Assignment
Briefly explain the difference the following pairs
of object-oriented terms. You should include
small examples to illustrate your answers:

class / object
attribute / operation
association / multiplicity
subclass / superclass
message / method
encapsulation / data hiding

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 21 (of 24)

Summary of Main Teaching Points


Introduction to OO Concepts
Introduction
Object-oriented concepts
Object
Class
Class Relationships
Generalization
Message
Encapsulation
Inheritance
CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 22 (of 24)

Question and Answer Session

Q&A
CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 23 (of 24)

Next Session
Introduction to UML Diagrams
Use Case Diagram
Sequence Diagram
Class Diagram

CT026-3-1 Systems Analysis and Design

Introduction to OO Concepts

Slide 24 (of 24)

You might also like