Introduction to Object Oriented Programming

Only available on StudyMode
  • Download(s) : 87
  • Published : March 30, 2013
Open Document
Text Preview
Computer Programming 2

Programming Paradigm

Procedural Programming




style of programming in which the
programming task is broken down into a series
of operations (called procedures) applied to
data (or data structures)
C and Pascal

Object-Oriented Programming





extension of procedural programming
breaks down a programming task into a series
of interactions among different entities or
objects
Java, C++, and Smalltalk

Introduction to OOP

* Property of STI
Page 1 of 15

Computer Programming 2

Object-Oriented
Programming
type of programming in which programmers
define not only the data structures, but also the
types of operations (methods) that can be
applied to the data structure
enables programmers to create modules that
do not need to be changed when a new type of
object is added
most widely used paradigm
instead of focusing on what the system has to
do, focus on:


what objects the system contains



how they interact towards solving the
programming problem

Introduction to OOP

* Property of STI
Page 2 of 15

1 _________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
2 _________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________

Computer Programming 2

Object-Oriented
Programming
Illustration of OOP

Introduction to OOP

* Property of STI
Page 3 of 15

Computer Programming 2

Object-Oriented
Programming
Advantages of OOP over conventional
approaches:


It provides a clear modular structure for
programs which makes it good for defining
abstract data types where implementation
details are hidden and the unit has a clearly
defined interface.



It makes it easy to maintain and modify existing
code as new objects can be created with small
differences from existing ones.



It provides a good framework for code libraries
where supplied software components can be
easily adapted and modified by the
programmer. This is particularly useful for
developing graphical user interfaces.

Introduction to OOP

* Property of STI
Page 4 of 15

3 __________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
4 __________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________
___________________

Computer Programming 2

Object-Oriented
Programming
Key OOP concepts:


Objects



Classes



Abstraction



Inheritance



Encapsulation



Polymorphism

Introduction to OOP

* Property of STI
Page 5 of 15

Computer Programming 2

Objects and Classes

Objects



represent “things” from the real world
made up of
• attributes – characteristics that define an object
• methods – self-contained block of program code
similar to procedure



example:
• a car’s attributes are make, model, year, and
purchase price
• a car’s methods are forward and backward

Classes







term that describes a group or collection of
objects with common properties
define a type of object
specifies methods and data that type of object
has
example:
• Employee
• Car

Introduction to OOP

* Property of STI
Page 6 of 15

5 _________________
___________________
___________________
___________________
___________________
___________________...
tracking img