Chapter One
Chapter One
Chapter One
INTRODUCTION TO OBJECT
ORIENTED PROGRAMMING
2
Outline
• Programming Paradigm
• Overview of Object Oriented Principles
• Java program types
• Java programming editing, compiling and
execution
3
Programming paradigm
• A programming paradigm is a fundamental style of computer
programming.
Procedural programming
• Based upon the concept of the procedure call.
• Specifying the steps the program must take to reach the desired state.
Procedural programming
• Possible benefits:
• Often a better choice than simple sequential or unstructured programming in many situations
which involve moderate complexity or require significant ease of maintainability.
• An easier way to keep track of program flow than a collection of "GOTO" or "JUMP" statements
(which can turn a large, complicated program into spaghetti code).
• The ability to be strongly modular or structured.
Procedural programming
• Scoping is another abstraction technique that helps to keep procedures
strongly modular(local/ global).
Procedural programming
• The focus of procedural programming is to break down a programming task
into a collection of variables, data structures, and subroutines, whereas in
object-oriented programming it is to break down a programming task into
objects with each "object" encapsulating its own data and methods
(subroutines).
Object-oriented programming
• Object-oriented programming (OOP) is a programming paradigm that
uses "objects" – data structures encapsulating data fields and procedures
together with their interactions – to design applications and computer
programs.
• Though it was invented with the creation of the Simula language in 1965,
and further developed in Smalltalk in the 1970s, it was not commonly
used in mainstream software application development until the early
1990s.
• One might say that a class is a blueprint or factory that describes the nature
of something.
• Collectively, the properties and methods defined by a class are called its
members.
11
• The set of values of the attributes of a particular object forms its state. The
object consists of the state and the behavior that's defined in the object's
class.
• In the case of a regular field (also called instance variable), for each instance of
the object there is an instance variable.
• A static field (also called class variable) is one variable, which is shared by all
instances.
• Attributes are an object’s variables that, upon being given values at instantiation
(using a constructor) and further execution, will represent the state of the object.
• A class is in fact a data structure that may contain different fields, which is defined
to contain the procedures that act upon it. As such, it represents an abstract data
type.
inside of a common “box”, thus creating the notion that an object contains its state
as well as its functionalities
• Information hiding refers to the notion of choosing to either expose or hide some
object. The result is that each object exposes to any class a certain interface —
those members accessible to that class.
• The reason for encapsulation aims at preventing unauthorized objects to change
they are available to all classes, sub-classes or only the defining class.
17
to method, field, or property calls of the same name, each one according to
an appropriate type-specific behavior.
• The programmer (and the program) does not have to know the exact type of
the object at compile time. The exact behavior is determined at run-time using
a run-time system behavior known as dynamic binding.
• Such polymorphism allows the programmer to treat derived class members
End of chapter!