Sie sind auf Seite 1von 5

Object-Oriented Programming

Something to Ponder
Suppose that you want to assemble your own PC, you go to a hardware store and pick up
a motherboard, a processor, some RAMs, a hard disk, a casing, a power supply, and put
them together. You turn on the power, and the PC runs. You need not worry whether the
CPU is 1-core or 6-core; the motherboard is a 4-layer or 6-layer; the hard disk has 4
plates or 6 plates, 3 inches or 5 inches in diameter; the RAM is made in Japan or Korea,
and so on. You simply put the hardware components together and expect the machine to
run. Of course, you have to make sure that you have the correct interfaces, i.e., you pick
an IDE hard disk rather than a SCSI hard disk, if your motherboard supports only IDE; you
have to select RAMs with the correct speed rating, and so on. Nevertheless, it is not
difficult to set up a machine from hardware components.
Similarly, a car is assembled from parts and components, such as chassis, doors, engine,
wheels, brake and transmission. The components are reusable, e.g., a wheel can be used
in many cars (of the same specifications).
Hardware, such as computers and cars, are assembled from parts, which are reusable
components.
How about software? Can you "assemble" a software application by picking a routine
here, a routine there, and expect the program to run? Unlike hardware, it is very difficult
to "assemble" an application from software components. Since the advent of computer
70 years ago, we have written tons and tons of programs. However, for each new
application, we have to re-invent the wheels and write the program from scratch.

-*-

Overview
In the early 1970s, the US Department of Defense (DoD) commissioned a task force to
investigate why its IT budget always went out of control; but without much to show for.
The findings are:
1. 80% of the budget went to the software (with the remaining 20% to the hardware).
2. More than 80% of the software budget went to maintenance (only the remaining
20% for new software development).
3. Hardware components could be applied to various products, and their integrity
normally did not affect other products. (Hardware can share and reuse! Hardware
faults are isolated!)
4. Software procedures were often non-sharable and not reusable. Software faults
could affect other programs running in computers.
The task force proposed to make software behave like hardware OBJECT. Subsequently,
DoD replaces over 450 computer languages, which were then used to build DoD systems,
with an object-oriented language called Ada.

-*-

Object-Oriented Programming (OOP) Definition


Object-oriented programming (OOP) is a programming language model organized
around objects rather than "actions" and data rather than logic.
It is a programming paradigm based on the concept of "objects", which are data
structures that contain data, in the form of fields, often known as attributes; and code,
in the form of procedures, often known as methods.
Historically, a program has been viewed as a logical procedure that takes input
data, processes it, and produces output data.
1 | I T E P 3 0 9 Object Oriented Programming
Percival A. Fernandez

Object-Oriented Programming
The programming challenge was seen as how to write the logic, not how to
define the data.
Object-oriented programming takes the view that what we really care about are
the objects we want to manipulate rather than the logic required to manipulate
them.
Examples of objects range from human beings (described by name, address,
and so forth) to buildings and floors (whose properties can be described and
managed) down to the little widgets on a computer desktop (such as buttons
and scroll bars).
In OO programming, computer programs are designed by making them out of objects
that interact with one another. There is significant diversity in object-oriented
programming, but most popular languages are class-based, meaning that objects
are instances of classes, which typically also determines their type.

Object-oriented modeling
Object-oriented modeling (OOM) is the construction of objects using a collection
of objects that contain stored values of the instance variables found within an object.
Unlike models that are record-oriented, object-oriented values are solely objects.
Object-oriented modeling is the process of preparing and designing what the models
code will actually look like. During the construction or programming phase, the
modeling techniques are implemented by using a language that supports the objectoriented programming model.
Object-oriented modeling is an approach to modeling an application that is used at
the beginning of the software life cycle when using an object-oriented approach to
software development.
The software life cycle is typically divided up into stages going from abstract
descriptions of the problem to designs then to code and testing and finally to
deployment.
Modeling is done at the beginning of the process. The reasons to model a system
before writing the code are:
Communication.

Users typically cannot understand programming language code.


Model diagrams can be more understandable and can allow users to give
developers feedback on the appropriate structure of the system.
A key goal of the Object-Oriented approach is to decrease the "semantic
gap" between the system and the real world, to have the system be
constructed using terminology that is the same as the functions that users
perform.
Abstraction.
A goal of most software methodologies is to first address "what" questions
and then address "how" questions. I.e., first determine the functionality the
system is to provide without consideration of implementation constraints
and then consider how to take this abstract description and refine it into an
implementable design and code given constraints such as technology and
budget.
Modeling enables this by allowing abstract descriptions of processes and
objects that define their essential structure and behavior.
Object-oriented modeling provides a vehicle to represent the properties,
behavior and interaction of things.
2 | I T E P 3 0 9 Object Oriented Programming
Percival A. Fernandez

Object-Oriented Programming
Object-oriented modeling is typically done via use cases and abstract definitions of
the most important objects. The most common language used to do object-oriented
modeling is the Object Management Group's Unified Modeling Language (UML)
In order to implement these models so they can be used through a computer,
a programming language is required these are called object-oriented
programming (OOP) languages.
Object-Oriented Programming Languages
Many of the most widely used programming languages are multi-paradigm
programming languages that support object-oriented programming to a greater or
lesser degree, typically in combination with imperative, procedural programming.
There is a wide range of OOP languages from which to choose. Different
languages support different degrees of object-orientation, but all provide
mechanisms to implement the basic concepts.

A programming paradigm is a fundamental style of computer programming,


serving as a way of building the structure and elements of computer programs.
Capabilities and styles of various programming languages are defined by their
supported programming paradigms; some programming languages are designed
to follow only one paradigm, while others support multiple paradigms.
A multi-paradigm programming language is a programming language that
supports more than one programming paradigm.
As Leda designer Timothy Budd puts it: "The idea of a multi-paradigm language is
to provide a framework in which programmers can work in a variety of styles,
freely intermixing constructs from different paradigms." The design goal of such
languages is to allow programmers to use the best tool for a job, admitting that no
single paradigm solves all problems in the easiest or most efficient way.

Simula was the first object-oriented programming language. Java, Python, C+


+, Visual Basic .NET and Ruby are the most popular OOP languages today.
The Java programming language is designed especially for use in distributed
applications on corporate networks and the Internet. Ruby is used in many Web
applications.
Significant object-oriented languages include Python, C++, Objective-C, Smalltalk,
Delphi, Java, C#, Perl, Ruby and PHP.
The most popular programming languages are Java, C++ and Visual Basic.

Java
Java is one of the purest OOP languages. It was designed from the ground up
with objects in mind and is widely used in a range of Internet as well as standalone applications. Additionally, the majority of applications running on mobile phones
and some PDAs are developed in Java.
C++
One of the most popular programming languages among computer programmers
is C. About a decade ago it was extended with object-oriented elements and was
then called C++. The majority of applications running on Microsoft Windows, Mac
OS and Linux are
written in C++.
Microsoft has recently introduced C# (speak: C sharp) which is a popular variant
of C++ that has been integrated in the Microsoft.Net Framework.
3 | I T E P 3 0 9 Object Oriented Programming
Percival A. Fernandez

Object-Oriented Programming
Visual Basic
One of the most popular programming languages is Microsoft Visual Basic. Visual
Basic, like C, was initially designed as a procedural programming language. In recent
versions, object-oriented elements have been added and, since it has been integrated in
the Microsoft.Net Framework, it is now widely accepted as an OOP language.
OOP Flow and Control
OOP languages, in contrast to the other programming techniques, have a web of
interacting objects sending messages to each other.
Strengths of OOPs
More opportunity for reuse
Models the real world more accurately
Naturalness ("objects concept")
Increased quality
Encapsulation and abstraction (higher cohesion/lower coupling)
Easier maintenance
Enhanced modifiability
Weaknesses of OOPs
Can run slower
Can be complex
Can take more memory
Benefi ts of OOP
The procedural-oriented languages focus on procedures, with function as the basic unit.
You need to first figure out all the functions and then think about how to represent data.
The object-oriented languages focus on components that the user perceives, with objects
as the basic unit. You figure out all the objects by putting all the data and operations that
describe the user's interaction with the data.
Object-Oriented technology has many benefits:
Ease in software design: as you could think in the problem space rather than the
machine's bits and bytes. You are dealing with high-level concepts and abstractions.
Ease in design leads to more productive software development.
Ease in software maintenance: object-oriented software are easier to understand,
therefore easier to test, debug, and maintain.
Reusable software: you don't need to keep re-inventing the wheels and re-write the
same functions for different situations. The fastest and safest way of developing a
new application is to reuse existing codes - fully tested and proven codes.
Object Oriented Programming versus Procedural Programming
Object Oriented Programming (OOP) and Procedural Programming are two
programming paradigms.
A programming paradigm is a fundamental style of computer programming, and
they differ in the way different elements of the program are represented and how
steps for solving problems are defined.

As the name suggests, OOP focuses on representing problems using real-world


objects and their behavior while, Procedural Programming deals with representing
solutions to problems using procedures, which are collections of code that run in a
specific order.
4 | I T E P 3 0 9 Object Oriented Programming
Percival A. Fernandez

Object-Oriented Programming

There are programming languages that support key aspects of OOP (called OOP
languages), Procedural (called Procedural languages) and both. But one important
thing to note is that OOP and Procedural are two ways of representing problems to
be solved, and it does not matter which language is used.

In other words, OOP languages can be used for Procedural Programming while
Procedural languages can sometimes be used for OOP, with some effort.
Procedural Programming is a way of programming by identifying the set of steps to
solve a certain problem and the exact order that they should be executed to reach the
desired outcome or state.
For example, if you want to calculate the month-end closing balance for a bank
account, then the required steps would be as follows.
First, you acquire the starting balance of the account and then you reduce all
the debit amounts occurred during the month.
After that, you add all the credit amounts occurred during the month. At the end
of the process, you will get the month-end closing balance of the account.
One of the main concepts of Procedural Programming is the Procedure call. A
procedure also known as a subroutine, method or a function contains an ordered
list of instructions to be carried out.
A procedure can be called at any time during the execution by any other procedure
or by itself. Examples of Procedural programming languages are C and Pascal.
In Object Oriented Programming, the focus is on thinking about the problem to be
solved in terms of real-world elements and representing the problem in terms of
objects and their behavior.
Object is a data structure that closely resembles some real-world object. Objects
contain data fields and methods that represent attributes and behavior of real-world
objects.
There are several important OOP concepts such as Data abstraction,
Encapsulation, Polymorphism, Messaging, Modularity and Inheritance.

Some popular OOP languages are Java and C#. However, they can be used to
perform Procedural Programming as well.
The key difference between OOP and Procedural Programming is that:
The focus of Procedural Programming is to break down the programming task in to
a collection of variables and subroutines.
The focus of OOP is to break down the programming task in to objects, which
encapsulate data and methods.
o

Most notable difference could be that while Procedural Programming uses


procedures to directly operate on data structures, OOP will bundle the data and
methods together so that an object will operate on its own data.

When it comes to the nomenclature, procedure, module, procedure call and


variable in Procedural Programming are often referred to as method, object,
message and attribute in OOP, respectively.

5 | I T E P 3 0 9 Object Oriented Programming


Percival A. Fernandez

Das könnte Ihnen auch gefallen