The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.

Object-oriented Analysis And Design, Object-oriented Programming, Object-oriented Concepts and Object-oriented Advantages

Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by Ts. Nik Maria Bt. Nik Mahamood, 2020-06-21 00:45:13

Chapter 1: Introduction to Object-Oriented

Object-oriented Analysis And Design, Object-oriented Programming, Object-oriented Concepts and Object-oriented Advantages

Keywords: OO,Java

DDWC 2623
OBJECT - ORIENTED PROGRAMMING USING JAVA

CHAPTER 1: INTRODUCTION TO OBJECT-
ORIENTED

Prepared By:

Ts. Nik Maria binti Nik Mahamood
Course Coordinator

Reference:
Bennett, McRobb, Farmer, Object-Oriented Systems Analysis And Design using UML, Fourth
Edition, Mc Graw Hill.

INSPIRING CREATIVE AND INNOVATIVE MINDS

INTRODUCTION TO OBJECT - ORIENTED

1.1 What It Is Object-oriented Analysis And Design?
1.2 What It Is Object-oriented Programming
1.3 Object-oriented Concepts
1.4 Object-oriented Advantages

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.1 WHAT IS OOAD?

• OOAD is a generic term for the ideas behind the process
we employ to analyze a problem and develop logical
solution from the perspective of objects
(things, concepts, or entities)

• Small problems do not require an exhaustive process, it is
sufficient to write pseudo code before we begin writing
code.

MORE INFO:
- Pseudo code can suffice for small problem
- Problem increase in size, the methods of OOAD becomes involve.

INSPIRING CREATIVE AND INNOVATIVE MINDS

WHAT IS OOA?

• Object-Oriented Analysis
– During OOA, there is an emphasis on finding and
describing the concepts or objects in the problem
domains.
– For example:
• In the case of the library information system. Some
of concepts include Book, Librarian, Borrower

MORE INFO:
See Figure 1.1 : Object-orientation emphasizes representation objects.

INSPIRING CREATIVE AND INNOVATIVE MINDS

WHAT IS OOD?

• Object-Oriented Design
– During OOD, there is an emphasis on defining software
objects and how they collaborate to fulfill the
requirements.
– For example:
• In the library system, a Book software may have a
title attribute and a getChapter method.

MORE INFO:
See Figure 1.1 : Object-orientation emphasizes representation objects.

INSPIRING CREATIVE AND INNOVATIVE MINDS

Domain Book Visualization of
concept Title domain concept

getChapter(no:int)

Representation in public class Book
an OOP language {
private String title;

public Chapter getChapter(int) {…}
}

Figure 1.1 : Object-orientation emphasizes representation objects.

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.2 WHAT IS OOP?

• If you've never used an object-oriented language before,
you need to understand the underlying concepts before
you begin writing code.

• Defined in terms of objects and the relationships between
them. Therefore, you need to understand:
– What an object is?
– What a class is?
– How objects and classes are related
– How objects communicate by using messages

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.2 WHAT IS OOP?

Class 1 { Class 2 {
Data Data
Methods Methods

} }

Class n {
Data
Methods

}

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.2 WHAT IS OOP?

• An object-oriented program is made up of objects.
• It groups operations and data into modular units called

objects
• In an object-oriented programming language, objects and

object interactions are the basic elements of design.
• Every object has both state (data or attribute) and

behavior (operation or function) on data.
• Objects from the same class have the same data elements

and methods
• Objects send and receive messages to invoke actions.

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.2 WHAT IS OOP?

Functional/data approach Object-oriented approach

Data Objects

Functions

Figure 1.2: Functional/data VS object-oriented

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.2 WHAT IS OOP?

• Structure Programming Global data

Main program

Function 1 Function 2 Function 3

Function 4 Function 5

1.2 WHAT IS OOP?

Structured programming
• Structured programming using function
• Function & program is divided into modules
• Every module has its own data and function which can be

called by other modules.
• Example of Structured programming language

C
 Pascal

INSPIRING CREATIVE AND INNOVATIVE MINDS

OO programming 1.2 WHAT IS OOP?

Object 1 Object 2
Data
Data Function
Function

Object 3
Data
Function

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.2 WHAT IS OOP?

OO programming
• Objects have both data and methods
• Objects of the same class have the same data elements

and methods
• Objects send and receive messages to invoke actions
• Example of Object-oriented programming languages:

 Java
 C++
 Object-Pascal
 Smalltalk

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.2 WHAT IS OOP?

OO programming
• Objects have both data and methods
• Objects of the same class have the same data elements

and methods
• Objects send and receive messages to invoke actions
• Example of Object-oriented programming languages:

 Java
 C++
 Object-Pascal
 Smalltalk

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.2 WHAT IS OOP?

Key idea in object-oriented:
The real world can be accurately described as a

collection of objects that interact.

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.2 WHAT IS OOP?

Basic Terminology in Object-Oriented

Object
• An object - bundle of related variables and methods.
• Often used to model real-world objects that we find in

everyday life.
• Every object is an instance of (belongs to) a class.
• objects interact and communicate with each other using

messages.
• Example: person, place, thing (a noun)

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.2 WHAT IS OOP?

Basic Terminology in Object-Oriented

Method
• A method - action performed by an object.
• Also known as function/operation
• Example:

move()
StudRegister()
calculateCPA()

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.2 WHAT IS OOP?

Basic Terminology in Object-Oriented
Attribute
• An attribute – description of object in a class.
• Also known as state/data.

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.2 WHAT IS OOP?

Basic Terminology in Object-Oriented

Class
• A class - blueprint or prototype that defines the variables

and the methods common to all objects of a certain kind.
• In simple terms a class is just a template for the object.
• Example:

Class: Student
Attributes: Name, course, year, cpa, cgpa, status
Method: addSubject(), dropSubject(), studResult()
Object: Ahmad, Siti, Aisyah, Sarah and etc.

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.2 WHAT IS OOP?

Basic Terminology in Object-Oriented

For example:
Julie's car is an object. It has an state consisting of 'amount
of fuel', 'make of car', 'number of miles driven' and 'colour'
and it responds to the operations 'drive n miles', 'how many
miles have you driven?‘

Explanation:
Car is an example of a class. To make a 'real' car you have to
instantiate the class, and then you get an object such as
Julie's car which is a green Metro , Fred's car which is a red
Volvo.

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.3 OO CONCEPTS

• There are four main principles of object-oriented
programming
– Abstraction
– Encapsulation
– Inheritance
– Polymorphism

INSPIRING CREATIVE AND INNOVATIVE MINDS

Abstraction & Encapsulation

• Abstraction
– Focuses on a simplified outside view of behavior,
rather than implementation (e.g. What versus How).
– For example: You talk on the phone without
considering how the signals are transmitted.

• Encapsulation
– Enclose data inside an object
– Cannot be accessed directly from outside
– Provides data security
– Also known as data hiding.

INSPIRING CREATIVE AND INNOVATIVE MINDS

Inheritance

• Inheritance
– The concept of using classes provides a useful way to
organize objects;
• it is especially useful because classes are reusable
or extensible.
– Inheritance means you can create new classes that
extend or are descendents of existing classes.
– The descendent classes can inherit all the attributes of
the origins (parent) class.
– Because of OOP allows inheritance, you can build
classes that are extension of existing class without
start fresh each time you want to create class.

INSPIRING CREATIVE AND INNOVATIVE MINDS

Polymorphism

• Polymorphism
– This ability of different objects to respond, each in its
own way, to identical messages is called
polymorphism.
– Concept of polymorphism is “one interface multiple
method”
– Object-oriented programs use polymorphism to carry
out the same operation in a manner customized to the
object.
– Eg. Superclass ‘Polygon’ has a method named getArea
getArea in Subclass ‘Triangle’  a=x*y/2
getArea in Subclass ‘Rectangle’  a=x*y

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.4 OO ADVANTAGES

• Re-usability

- once an object class is created it can be used in other
applications

• Reliability

- reused objects have already been tested

• Extensibility

– Can derive a new class from the existing class.

QUESTION:
Discuss the concepts and advantages object-oriented approach.

INSPIRING CREATIVE AND INNOVATIVE MINDS

1.4 OO ADVANTAGES

• Implementation of complex program

– OO closely reflect to the real world
– So that more easier to understand the concept

• Save development time ( and cost)

- by reusing code
- once an object class is created it can be used in other

applications

• Easier debugging

– classes can be tested independently

QUESTION:
Discuss the concepts and advantages object-oriented approach.

INSPIRING CREATIVE AND INNOVATIVE MINDS


Click to View FlipBook Version