You are on page 1of 29

Object Oriented Programming using Java

Lecture 01-02
An Introduction to the Course

Imran Daud
Foundation University
Institute of management and computer sciences

Imran Daud
FUIMCS
Introduction

• Pre-requisite: Introduction to Programming


– The most fundamental course and is going to form the foundation for
subsequent ones

• Credits: 3+1 Contact Hrs: 3+3


– Two lectures/per week one hour 15 mins each
– 3 hours lab/ week

Imran Daud
FUIMCS
Objective
• To introduce students the basic Object Oriented
programming skills with an aim to:

– Familiarize the most powerful features of Java programming


focusing on OOP methodology

– Emphasize the correct and proper use of object-oriented support in


Java

Imran Daud
FUIMCS
Recommended Books and Other Material

• Text Book
– Object Oriented Programming in C++ by Robert Lafore
• Some good reference books are
– Beginning C++ By Ivor Horton
– C++ Premier Plus 4th Edition by Stephen Prata
– C++ How to Program 4th edition by Deitel and Deitel
– Thinking in C++, By Bruce Eckel
– Computing Essentials with C++ Concepts by Cay Horstman
– Programming and Problem Solving with C++ by Nell Dale
• Lecture Slides
• Any other material on Object Oriented Programming

Imran Daud
FUIMCS
Course Contents

• Motivation for Object Oriented Approach


• C++ Language Fundamentals
– Pointers in Function
– ‘const’ Modifier & Pointers
– Dynamic Memory Allocation in C++
– Structures in C++, and Dynamic Memory Allocation in C++
Object Oriented Concepts
– C++ Class Declaration,
– C++ Class Members,
– C++ Access Modifiers
– Encapsulation
– Information Hiding, Constructors etc

Imran Daud
FUIMCS
Course Contents

• Operator Overloading in C++


• Inheritance in C++
• Virtual Functions and Polymorphism
• Exceptions in C++
• C++ Stream Input/Output
• Templates
• Standard Template Library (STL)

Imran Daud
FUIMCS
Administrative

• Instructor: Imran Daud


– fuimcs@hotmail.com
• Office hours:
– 9-3

Imran Daud
FUIMCS
Quizzes

• Quizzes will generally be unannounced


• After 1st week you can expect a quiz every week
• Missing a quiz means zero marks
• A Quiz may also be conducted at anytime during the lecture

Imran Daud
FUIMCS
Assignments

• There will be 4-5 assignments


• Related to the topics being studied in course
• DO NOT copy assignments
– Both of the copy cases will be graded zero
• Submission time will be 1500 hrs on the due date
– NO credit on LATE submission of any deliverable.
• No excuse of USB/Floppy/email servers not working
• Sorry! No Exceptions

Imran Daud
FUIMCS
Lab Work

• Involves implementation of studied techniques and data structures.

• Coding in C++ using Visual Studio IDE

• Each lab comprise of a lab exercise to be submitted during the same lab
time (2 Hrs.)
• Lab assignments to be submitted individually

Imran Daud
FUIMCS
Project

• You will be required to do a project after your One Hour


exam

• You will have full liberty to choose any application of your


choice but your project proposals should reach my office
by the 2nd week after your first OHT

Imran Daud
FUIMCS
Evaluation Breakdown

– OHT(30) = 30%
– Final = 50%
– Quizzes = 5 %
– Assignments = 5 %
– Project = 10 %

Imran Daud
FUIMCS
Attendance Policy

• A person who comes late will also be marked absent

• As per FUIMCS attendance regulations, a student missing more then


25% of the classes qualifies for action.

Imran Daud
FUIMCS
OOP ABC

Imran Daud
FUIMCS
Why We Need OOP

• OOP was developed to overcome the limitations of the


traditional programming languages. Instruct
at each
step

• As the programs gets larger in procedural programming it


becomes more complex to understand the logic and
implement.

Imran Daud
FUIMCS
Problems with UNstructured approach
• Unrestricted access

Accessible by any function

Accessible Global Variables Accessible


only by only by
function A function B
Function A Function B

Local Variables local Variables

Imran Daud
FUIMCS
Problems with UNstructured approach
-difficult to conceptualize
- Change in global variable
causes rewriting
dependent functions

Global Data Global Data Global Data

Function Function Function Function

Imran Daud
FUIMCS
Object Oriented Approach
• The fundamental idea behind object-oriented language is to
combine both in a single unit
– data and
– the functions that operate on that data.
– Such a unit is called an object

• Data and its functions are said to be encapsulated into a single


entity
• Data encapsulation and data hiding are the key terms in the
description of object oriented languages

Imran Daud
FUIMCS
Object Oriented Approach

Data

Member
Function

Member
Function

Object
Data
Data
Member
Member
Function
Function
Member Member
Function Function

Object Imran Daud Object


FUIMCS
Real World Modeling

• In physical world we deal with objects such as cars and


people
• Such kind of objects are not like the data and are not like
the functions
• Complex real world objects have both attributes and
behavior

Imran Daud
FUIMCS
Attributes
• Sometimes called characteristics
• Example:
– People: Eye color and job title
– Cars: horsepower and number of doors

• Attributes in the real world are equivalent to the data in a


program.
• They have certain specific values such as blue (for eye
color) and four (for the number of doors)

Imran Daud
FUIMCS
Behavior

• Behavior is something a real world object does in response


to some stimulus.
• Example:
– Saying something
– Stopping by applying brakes

• Behavior is like a function. You call a function to do


something.

Imran Daud
FUIMCS
Why Objects?

A new way to think about software


Industrial revolution -- reuse software, not rewrite
Increase
– programmer productivity
– quality of software
– understandability of software
– lifetime of software

Imran Daud
FUIMCS
Characteristics of Object Oriented
Languages

• When you approach Object-Oriented Language you no


longer ask how the problem will be divided into functions,
but how it will be divided into objects.

• This results from the close match between objects in the


programming sense and objects in the real world

Imran Daud
FUIMCS
Kinds of Objects

• What kinds of things become objects in Object-Oriented


programs?
• Physical objects
– Automobiles in a traffic flow simulation
– Electrical components in a circuit-design program
– Countries in an economics model
– Aircraft in an air traffic control system

Imran Daud
FUIMCS
Kinds of Objects
• Elements of the computer-user environment
– Windows
– Menus
– Graphics objects (lines, rectangles, circles)
– The mouse, keyboard, disk drives, printer
• Human Entities
– Employees
– Students
– customers

Imran Daud
FUIMCS
OO Programming Methodology

• Objects are self-contained “mini-programs”


– Each object has a specific set of responsibilities
– Operations (methods), and data form an interface

• Reusable Components
– Design or build new applications from existing object components
– Build new objects from existing objects

Imran Daud
FUIMCS
Objects and Behavior

John goes on a trip. Can you


think of
John makes reservations. various
John buys tickets. possible
John travels by airplane. Objects?

John checks into hotel.

Imran Daud
FUIMCS
OO Programming Methodology
• A Programming Methodology
– A different way to think about problems
– Adopt a new programming “Mindset”

• Models Real World


– Easier to identify, conceptualize, explain and document

• Objects are Primary Focus


– Data and functions or responsibilities are united in OBJECTS

Imran Daud
FUIMCS

You might also like