CSC2071 - Lecture 07 (OO Principles)
CSC2071 - Lecture 07 (OO Principles)
CSC2071
Lecture No. 07
Muhammad Shahid
Department of Computer Science
National Textile University
[email protected]
Recap
Arrays
Multidimensional Arrays
‒ Rectangular arrays
‒ Jagged arrays
Arrays as Arguments
Arrays as Return values
The System.Array Base Class
What is Object-Orientation?
Procedural Programming Paradigm
Object Oriented Programming Paradigm
Benefits of Object-Orientation
Object-Oriented Principles
Application is divided into 4 modules Modules C carries out 3 tasks (X, Y, Z) Procedure Y calls function P and Q
Application is collection of 4 Packages Packages B contains 3 classes (P, Q, R) Class R encapsulates 7 methods
( m1.. m7) and 3 attributes ( x, y, z)
Object X of Class R
Data
Message to invoke m4() 3,8,1 Data/Object out
Modularity
‒ Source code for an object can be maintained
independently in a class. Once created, an
object can be easily passed around inside the
system.
Code Re-use
‒ If an object already exists, you can use that
object in the program. This allows specialists to
implement/test/debug complex, task-specific
objects, which you can then trust to run in your
own code.
11 Object Oriented Programming – CSC2071
Benefits of Object-Orientation
Information-hiding
‒ By interacting only with an object's methods,
the details of its internal implementation remain
hidden from the outside world
Plug-ability and debugging ease
‒ If a particular object turns out to be problematic,
you can simply remove it from the application
and plug in a different object as its replacement.
This is analogous to fixing mechanical problems
in the real world.
1. Encapsulation
2. Abstraction
3. Inheritance
4. Polymorphism
Private Area
No Entry Private Data
Private Functions
Public Area
Entry Allowed
Public Data
Public Functions
[G. Booch]
Tandem Bike
Mountain Bike Road Bike
What is Object-Orientation?
Procedural Programming Paradigm
Object Oriented Programming Paradigm
Benefits of Object-Orientation
Object-Oriented Principles