0% found this document useful (0 votes)
4 views

Advances Java 2

The document introduces Object Oriented Programming (OOP), explaining its evolution from machine languages to high-level languages, and detailing the characteristics of procedural and object-oriented languages. It emphasizes the concept of objects, classes, and methods, highlighting how OOP allows for data modeling and reusability through encapsulation and inheritance. Key terminology and examples illustrate the relationship between classes and objects, as well as the importance of object interaction in programming.

Uploaded by

James Bataller
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Advances Java 2

The document introduces Object Oriented Programming (OOP), explaining its evolution from machine languages to high-level languages, and detailing the characteristics of procedural and object-oriented languages. It emphasizes the concept of objects, classes, and methods, highlighting how OOP allows for data modeling and reusability through encapsulation and inheritance. Key terminology and examples illustrate the relationship between classes and objects, as well as the importance of object interaction in programming.

Uploaded by

James Bataller
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Introduction of

Object Oriented
Programming
Topic 2

Created by: Mr. Rogie Montoya


Subject: Advance Java
Computer Programming

An algorithm is a step-by-step process.

A computer program is a step-by-step set of instructions for a


computer.

Every computer program is an algorithm.


Computer Programming

The history of computer programming is a steady move away from


machine-oriented views of programming towards concepts and
metaphors that more closely reflect the way in which we ourselves see
& understand the world
Computer Programming

• Programming languages allow programmers to develop software.

• The three major families of languages are:


– Machine languages
– Assembly languages
– High-Level languages
Machine Languages

• Comprised of 1s and 0s
• The “native” language of a computer
• Difficult to program – one misplaced 1 or 0 will cause the program to
fail.
• Example of code: 1110100010101 111010101110 10111010110100
10100011110111
Assembly Languages

• Assembly languages are a step towards easier programming.


• Assembly languages are comprised of a set of elemental commands
which are tied to a specific processor.
• Assembly language code needs to be translated to machine
language before the computer processes it.
• Example: ADD 1001010, 1011010
High-Level Languages

• High-level languages represent a giant leap towards easier


programming.
• The syntax of HL languages is similar to English.
• Example:
 grossPay = basePay + overTimePay
 Interpreter – Executes high level language programs without
compilation.
• Historically, we divide HL languages into two groups:
– Procedural languages
– Object-Oriented languages (OOP)
Procedural Languages

• Early high-level languages are typically called procedural languages.


• Procedural languages are characterized by sequential sets of linear
commands. The focus of such languages is on structure.
• Examples include C, COBOL, Fortran, LISP, Perl, HTML, VBScript
Object-Oriented Languages

• The focus of OOP languages is not on structure, but on modeling


data.
• Programmers code using “blueprints” of data models called classes.
• Examples of OOP languages include C++, Visual Basic.NET and Java.
Early programming
languages
Modern programming
languages
Simula

• is a name for two simulation programming languages, Simula I and


Simula 67, developed in the 1960s at the Norwegian Computing
Center in Oslo, by Ole-Johan Dahl and Kristen Nygaard.
• Simula is considered the first object-oriented 14 programming
language.
• Simula was designed for doing simulations, and the needs of that
domain provided the framework for many of the features of object-
oriented languages today.
Object Oriented
Programming

• OOP is mainly a program design philosophy.


• OOP uses a different set of programming languages than old
procedural programming languages (C, Pascal, etc.).
• Everything in OOP is grouped as self sustainable "objects". Hence,
you gain re-usability by means of four main object-oriented
programming concepts.
Object Oriented
Programming

• In OOP programmers define not only the data type of a data


structure, but also the types of operations/methods (functions) that
can be applied to the data structure.
• In this way, the data structure becomes an object that includes both
data and functions (methods) in one unit. In addition, programmers
can create relationships between one object and another.
• For example, objects can inherit characteristics from other objects.
Object Oriented
Programming Languages

• Pure OO Languages
Eiffel, Actor, Emerald, JADE, Obix, Ruby, Python, Scala, Smalltalk, Self.
• Hybrid OO Languages
Delphi/Object Pascal, C++, Java, C#, VB.NET, Pascal, Visual Basic,
MATLAB, Fortran, Perl, COBOL 2002, PHP, ABAP, Ada 95.
Object Oriented
Programming

• Key idea in object-oriented:

The real world can be “accurately” described as a collection of objects


that interact.
OOP Basic Terminology

• Object
– usually a person, place or thing (a noun)
• Method
– an action performed by an object (a verb)
• Property or attribute
– Characteristics of certain object.
• Class
– a category of similar objects (such as automobiles), does not hold
any values of the object’s attributes/properties
Classes and Objects

• A class is a prototype, idea, and blueprint for creating objects.


• An object is an instance of a class.
• For example, in Java we define classes, which in turn are used to
create objects
• A class has a constructor for creating objects
• Class is composed of three things: its name, attributes/properties,
and methods.
Classes and Objects
Classes and Objects
Classes Example
Almost everything in the world can be
represented as an object
• A flower, a tree, an animal
• A student, a professor
• A desk, a chair, a classroom, a building
• A university, a city, a country
• The world, the universe
• A subject such as CS, IS, Math, History,…
• An information system, financial, legal,
etc..
What Is an Object, again?
• An object is an instance of a class
More about objects
More formal definition
of an “Object”
An object is a computational entity that:
1. Encapsulates some state
2. Is able to perform actions, or methods, on this state
3. Communicates with other objects via message passing
Classes and Objects
Classes and Objects
Classes and Objects
Classes and Objects
In short…

• An Object is a Class when it comes alive!


• Homo Sapien is a class, John and Jack are objects
• Animal is a class “Snowball” the cat is an object
• Vehicle is a class My neighbor's BMW is an object
• Galaxy is a class, the MilkyWay is an object
Technical contrast
between Objects &
Classes
Objects Need to Collaborate!
• Objects are useless unless they can collaborate
together to solve a problem.
– Each object is responsible for its own behavior and
status.
– No one object can carry out every responsibility on
its own.
• How do objects interact with each other? – They
interact through messages.
Object Interaction
Example of Object
Interaction

You might also like