0% found this document useful (0 votes)
0 views12 pages

EEI3262 Unit 1 Session 1

This document provides an overview of Object Oriented Programming (OOP), focusing on its principles, history, and the Java programming language. It discusses the evolution of programming paradigms, the significance of OOP in software development, and the tools such as Integrated Development Environments (IDEs) that facilitate programming. The session also covers the Java Development Kit (JDK), the concept of the Java Virtual Machine (JVM), and the Just-In-Time (JIT) compiler, highlighting Java's platform independence.

Uploaded by

udarasenu
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)
0 views12 pages

EEI3262 Unit 1 Session 1

This document provides an overview of Object Oriented Programming (OOP), focusing on its principles, history, and the Java programming language. It discusses the evolution of programming paradigms, the significance of OOP in software development, and the tools such as Integrated Development Environments (IDEs) that facilitate programming. The session also covers the Java Development Kit (JDK), the concept of the Java Virtual Machine (JVM), and the Just-In-Time (JIT) compiler, highlighting Java's platform independence.

Uploaded by

udarasenu
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/ 12

Session 1 : Overview of Object Oriented Programming

SESSION 1
Overview of Object Oriented
Programming

Contents
Introduction, p1
1.1 Programming paradigms, p1
1.2 Object Oriented Paradigm, p2
1.3 Object Oriented Programming (OOP), p2
1.4 A Brief History of Object Oriented Programming, p3
1.5 Integrated Development Environments (IDEs), p4
1.6 Java, p5
1.7 Java Programming Environment, p8
Summary, p11
Learning outcomes, p11
Review questions, p12

Introduction
This session gives you an insight to Object Oriented Programming which is
one of the most powerful programming paradigms used in software
development today. This session will introduce you some popular terms
used in programming. There are many object oriented programming
languages, but in this session a major emphasis is given for Java. Therefore,
the key features of Java, Java Virtual Machine and Just-in-Time (JIT)
compiler will be further discussed in this session. In order to write software
or programs it is required to set up the necessary development platform first.
At the end of this session you will learn to set up your computer to start
write programs in Java. Let’s look at different programming paradigms exist
and the role of Object oriented programming paradigm in detail.

1.1 Programming paradigms


Before we start learning Object Oriented Programming paradigm let’s look
at what a ‘programming paradigm’ is in general. Programming paradigm is

1
Session 1 : Overview of Object Oriented Programming

a pattern, basic discipline or a way of thinking of programming a computer.


There are four main programming paradigms as given below:
 The imperative paradigm
 The functional paradigm
 The logical paradigm
 The object oriented paradigm
There are many more additional programming paradigms which are not
mentioned above. Further details on the four paradigms will be explained in
EEX3467– Software Engineering Concepts and Programming or EEX3417
– Software Development for Engineers course and we will be discussing
only on Object Oriented paradigm in this session.

1.2 Object Oriented Paradigm


Before the object oriented concepts emerged, a program was viewed as a
logical process that is organized around actions. For example, it might take a
date as an input, processes it, and produces output data. The programs use
this logical process or structure is referred to as Structured Programming.
In the recent decades with the increasing requirements of different
processes, programs became more complex. Hence it became difficult and
time consuming in order to create, manage and maintain programs using the
above procedure. In addition, the quality of programs became more vital and
the new technologies like Graphical User Interfaces (GUI), Internet, digital
and wireless technologies emerged. As a result, a need of more organized
procedures was required.
To solve above problems a new concept called ‘Object Oriented
Programming’ emerged which is further discussed in the next section.

1.3 Object Oriented Programming (OOP)


Let’s think of manufacturing a car. A car is manufactured by putting several
small parts or components together such as wheels, engine, frame, seats,
steering wheel etc. Similarly, we can develop software by breaking the
application into its component objects. These objects will interact with each
other and perform the required functionality of the software. To develop a
software using objects and their interactions it is required to have an object-
oriented approach. Object Oriented Programming (OOP) is a programming
technique that uses this approach, the concept of objects and their
interactions between them to design computer programs. The term objectis
explained further in session 5.
In OOP, a program needs to be seen as a collection of objects. The
interactions between these objects are carried out by sending and receiving
messages between objects. In addition, these objects are capable of

2
Session 1 : Overview of Object Oriented Programming

processing data. Each object can be viewed as an independent entity and


these objects have their own discrete tasks to perform.

1.4 A Brief History of Object Oriented Programming


Object-oriented programming concepts first emerged in 1960’s when a
group of Software Engineers were working on ship simulations. They
wanted to find out how the different characteristics of different ships could
affect one another. Finally, they decided to group the different types of ships
into different classes of objects where each class of object has its own data
and behaviour.
Hence, these concepts of objects were first introduced in the programming
language called ‘Simula 67’, by Ole-Johan Dahl and Kristen Nygaard who
were working in the Norwegian Computing Centre. These concepts were
then used in analog programming which was carried out using analog
computers. In 1970’s the term Object-oriented programming were
introduced in the language called ‘Smalltalk’ in order to represent the
concepts of objects and messages. Therefore, Smalltalk was the first
programming language to be called ‘object-oriented’.
This concept was not much popular until mid-1990’s with the popularity of
graphical user interfaces, event-driven programming and with the
development of computer games. After that, several object oriented
languages have emerged including C++, Java, Visual Basic. NET and C#.
Some of these programming languages are not fully object oriented but
support most of the object oriented concepts.

Activity 1.1: Evolution of Object Oriented Programming

Search in the internet and illustrate the timeline of at least ten popular Object Oriented
Programming languages from the first to up to date.

Use this space to draw the timeline

Simula I & Simula 67 Java

1960 1985

3
Session 1 : Overview of Object Oriented Programming

Activity 1.2: Object Oriented Programming Languages

Underline the object oriented programming languages from the given list.
1. JavaScript 6. C++ 11. Objective – C 16. TypeScript
2. Java 7. C# 12. Rust 17. VBA
3. Python 8. Smalltalk 13. Swift 18. Scala
4. Ruby 9. C 14. R 19. Lua
5. PHP 10. Visual 15. Matlab 20. Perl
Basic.NET

Some of the programming languages given above are multi-paradigm programming


languages and some languages are used for specific purposes such as for statistical
computing and graphics etc.

In this section you have learnt how different object oriented programming
languages evolved over a period. Next, we will look at the software tools
that can be used to ease the process of programming.

1.5 Integrated Development Environments (IDEs)


Now you know the Object Oriented Programming languages are different
from the rest of the programming paradigms and you can identify them.
Next, we will see the tools that we can use to do real developments using
these programming languages. One such type of tool is Integrated
Development Environments (IDEs). IDE is a software suite that combines
the basic tools developers need to write and test software. Typically, an IDE
contains an editor, a compiler or interpreter and a debugger that the
developer accesses through a single GUI. An IDE may be a standalone
application, or it may be included as part of one or more existing and
compatible applications.
During this course we will be using Java as your programming language to
get familiar with Object Oriented Programming. At this point you need not
to worry if you are not familiar with Java; an introduction to Java is given in
the next section and a detailed description is given though this material.
Eclipse, Netbeans, IntelliJIDEA and BlueJ are few of the IDEs that can be
used in Java program development.
We do not expect you to use an IDE when writing your programs in this
course we will be running the programs using the command prompt or
command line interpreter. You need to use a text editor such as notepad or
Notepad++ to write your programs.

4
Session 1 : Overview of Object Oriented Programming

Activity 1.3: Integrated Development Environments (IDEs)

Write down an IDE that you can use to develop programs for five (5) selected Object
Oriented Programming languages from what you have already underlined in Activity
1.2.

Search internet to find appropriate IDE for the programming languages and use the
given space to write down your answers.

1.
2.
3.
4.
5.

Now you are familiar with the development platforms that you can use to
write software programs using object oriented programming languages.
Next we will further learn Java.

1.6 Java
Java is a general purpose object oriented high level programming language,
developed by Sun Microsystems. General purpose programming languages
are unlike domain specific programming languages and allow programmers
to write software in wide variety of application domain. Java software
development was initiated in 1991 and released in 1995. Java is a popular
programming language which is used everywhere in software development.
Although we consider Java as an object oriented language, Java is not
considered as a pure object oriented language because of few reasons. These
reasons will be discussed in a later course.

1.6.1 Key features of Java


Some of the key features of Java are given below:
 OpenJDK (Open Java Development Kit) is a free and open
source implementation of the Java programming language with GNU
license that can be downloaded for free. GNU license is a widely used
free software license, which guarantees end users the freedom to run,
study, share and modify the software.
 Java is simple, reliable, secure and portable which can run on Windows,
Linux and many other operating systems. Since the programs written in
Java can be run on any platform or operating system, Java is considered
as a platform independent language.

5
Session 1 : Overview of Object Oriented Programming

 Java uses an automatic memory management strategy referred to as


automatic garbage collector in the object lifecycle. Automatic garbage
collection is not available in C and C++ programming languages.
Therefore, a memory management logic should be added to the
programs manually to reclaim the memory occupied by objects or code
that are no longer in used by the programs written in these languages. In
manual memory management, the programmer should specify which
objects to deallocate and return to the memory system. One of the
drawbacks in garbage collection is that you cannot completely control
this when it runs and when it does not.

1.6.2 Compiler and Interpreter


A program written in a high-level language cannot be run directly on any
computer. First, it must be translated into machine language. This
translation can be done by a program called a ‘compiler’. A compiler takes a
high-level-language program and translates it into an executable machine-
language program. Once the translation is done, the machine-language
program can be run any number of times, but it can only be run on one type
of computer, since each type of computer has its own individual machine
language. If the program is to run on another type of computer it must be re-
translated, using a different compiler, into the appropriate machine
language.
There is an alternative way of compiling a high-level language program.
Instead of using a compiler, which translates the program all at once, you
can use an interpreter, which translates the program instruction-by-
instruction. To execute a program, the interpreter runs in a loop in which it
repeatedly reads one instruction from the program, decides what is
necessary to carry out that instruction, and then performs the appropriate
machine-language commands to do so.
One use of interpreters is to execute high-level language programs. For
example, the programming language Lisp is usually executed by an
interpreter rather than a compiler. However, interpreters have another
purpose. They can let you use a machine-language program meant for one
type of computer on a completely different type of computer.
Once a program is compiled, usually there are dependencies with the
running architecture when implementing the program. But Java allows
application developers to ‘write once, run anywhere’ (WORA) their
applications. The compiled Java code can run on all platforms that support
Java without the need for recompilation. Java applications are typically
compiled to bytecode that can run on any Java Virtual Machine (JVM)
regardless of computer architecture.

1.6.3 Java Virtual Machine (JVM)


The designers of Java chose to use a combination of compilation and
interpretation. Programs written in Java are compiled into machine

6
Session 1 : Overview of Object Oriented Programming

language, but it is a machine language for a computer that doesn't really


exist. This so called "virtual" computer is known as the Java Virtual
Machine, or JVM. The machine language for the Java Virtual Machine is
called Java bytecode. There is no reason why Java bytecode couldn't be
used as the machine language of a real computer, rather than a virtual
computer. But the use of a virtual machine allows an application to run
on any computer. All that the computer needs is an interpreter for Java
bytecode. The interpreter implements the JVM. A different Java bytecode
interpreter is needed for each type of computer, but once a computer has a
Java bytecode interpreter, it can run any Java bytecode program, and the
same program can be run on any computer that has such an interpreter as
given in (Fig.1.1) This is one of the essential features of Java: the same
bytecode can be run on many different types of computers.

Figure 1.1: Java program compiler and interpreter

Activity 1.4: Platform Independence

Briefly explain how platform independence is achieved in a Java application

When Java was still a new language, it was criticized for being slow. Since
Java bytecode was executed by an interpreter; it seemed that Java bytecode
programs could never run as quickly as programs compiled into native
machine language. However, this problem has been largely overcome
using just-in-time (JIT) compilers for executing Java bytecode. JIT compiler
is further elaborated in the next section.

7
Session 1 : Overview of Object Oriented Programming

1.6.4 Just-In-Time (JIT) Compiler


A just-in-time compiler translates Java byte code into native machine
language. It does this while it is executing the program. Just as for a normal
interpreter, the input to a just-in-time compiler is a Java byte code program,
and its task is to execute that program. But as it is executing the program, it
also translates parts of it into machine language. The translated parts of the
program can then be executed much more quickly than they could be
interpreted. The processes get involved during the Java program compile
time and run time are given in (Fig.1.2). Since a given part of a program is
often executed many times as the program runs, a just-in-time compiler can
significantly speed up the overall execution time.

Figure 1.2: Just-In-Time (JIT) Compiler at run time

We will learn how to set up the Java development environment and how to
write a simple Java program in the next section.

1.7 Java Programming Environment


As discussed earlier, the environment for programming should be set before
start writing a program. Let’s look at how to install the software stack
required for Java programming.

1.7.1 Java Development Kit


The basic development system for Java programming is usually referred to
as the JDK (Java Development Kit). It is a part of Java SE, the Java
"Standard Edition" (as opposed to Java EE for servers or Java ME for
mobile devices). Note that Java SE comes in two versions, a Development
Kit version (the JDK) and a Runtime Environment version (the JRE). The
Runtime can be used to run Java programs, but it does not allow you to
8
Session 1 : Overview of Object Oriented Programming

compile your own Java programs. The Development Kit includes the
Runtime but also lets you compile programs. You need a JDK to use with
this course.
As explained in Session 1, Java was developed by Sun Microsystems, Inc.,
which is now a part of the Oracle corporation. Oracle makes the JDK for
Windows, Mac OS, and Linux available for free download at its Java Web
site. Many Windows computers come with a Java Runtime already installed,
but you might need to install the JDK. Some versions of Linux come with
the JDK either installed by default or on the installation media. If you need
to download and install the JDK, be sure to get the JDK for Java 7, Java 8,
or later. By the time of writing this course material JDK could be
downloaded from the given link
http://www.oracle.com/technetwork/java/javase/downloads/index.html

If the link does not work by the time you try to download the JDK, you can
use a search engine to find out where the latest version can be downloaded.
If a JDK is properly installed on your computer, you can use the command
line environment to compile and run Java programs. An IDE will also
require a JDK, but it might be included with the IDE downloaded.

1.7.2 Command Line Environment


Command line environment is very different from the graphical user
interfaces that most people are used to. However, it takes only a little
practice to learn the basics of the command line environment and to become
productive using it.
To use a command line programming environment, you will have to open a
window where you can type in commands. In Windows, you can open such
a command window by running the program named cmd. If you are using a
Linux distribution you must open the terminal console.
One of the central concepts in the command line environment is the current
directory which contains files that can be used by the commands that you
type. You can get a list of the files in the current directory by typing in the
command dir (on Windows) or ls (on Linux and Mac OS).
The most basic commands for using Java on the command line are javac
and java.
javac is used to compile Java source code, and java is used to run Java
standalone applications. If a JDK is correctly installed on your computer, it
should recognize these commands when you type them in on the command
line. Try typing the commands java -version and javac -
version which should tell you which version of Java is installed. If you get
a message such as "Command not found," then Java is not correctly
installed. If the "java" command works, but "javac" does not, it means
that a Java Runtime is installed rather than a Development Kit.

9
Session 1 : Overview of Object Oriented Programming

On Windows, after installing the JDK, you need to modify the Windows
PATH environment variable to make this work. Let’s see the instructions to
set the Windows PATH environment variable to Java.

1.7.3 Environment Variable


Set the PATH environment variable if you want to conveniently run the
executables (javac.exe, java.exe, javadoc.exe, and so on) from any directory
without having to type the full path of the command. If you do not set
the PATH variable, you need to specify the full path to the executable every
time you run it, such as:
C:\Java\jdk1.7.0\bin\javac MyClass.java
The PATH environment variable is a series of directories separated by
semicolons (;). Microsoft Windows looks for programs in
the PATH directories in order, from left to right. You should have only
one bin directory for the JDK in the path at a time (those following the first
are ignored), so if one is already present, you can update that entry.
The following is an example of a PATH environment variable:
C:\Java\jdk1.7.0\bin;C:\Windows\System32\;C:\Windows\;C:\Windows\System32\
Wbem
It is useful to set the PATH environment variable permanently so it will
persist after rebooting. To make a permanent change to the PATH variable,
use the System icon in the Control Panel. The precise procedure varies
depending on the version of Windows.

Activity 1.5: Install Java Development Kit(JDK) in your computer

You should create a directory (that is, a folder) to hold your Java work. For example,
create a directory named javawork in your home directory. You can do this using your
computer's GUI. Another way to do it is to open a command window, cd to the directory
that you want to contain the new directory and enter the command mkdir javawork.
When you want to work on programming, open a command window and use the cd
command to change into your work directory. You can have more than one working
directory for your Java work; you can organize your files any way you like.
After doing the activity 1.5, check the video given in the URL below to
check whether you have set up the Java Development Environment
correctly. This link is available in the online component of this course.

Setting up Java Development Environment:https://tinyurl.com/setupJava-


OUSL

10
Session 1 : Overview of Object Oriented Programming

Summary
A paradigm shift has happened in programming as in any other discipline.
Object Oriented Paradigm is one of the four main programming paradigms.
Imperative paradigm, functional paradigm and logical paradigm were not
discussed in this session. In object oriented paradigms, software is
considered to be developed by the smallest entity called “objects”. The
approach of developing the software by considering the objects and the
interactions between the objects is referred to as “Object Oriented
Programming”. Many programming languages are being used in different
programming paradigm. Simula is considered as the first object oriented
programming language. Simula consisted of two programming languages,
Simula I and Simula 67. There after many object oriented programming
languages are being developed and used in the industry. C++, C#, Python
and Java are few of the object oriented programming languages. Some of
them such as Java and Python are not fully object oriented. In order to
develop software, it is required to set up the development environment for
the programming language. Installing an Integrated Development
Environment or an IDE is an integral part when setting up the programming
development environment. Eclipse, Netbeans, IntelliJ IDEA and BlueJ are
few of such IDEs that can be used to write programs in Java. Java has some
key features. Having a free and open source implementation, OpenJDK
(Open Java Development Kit) is one key feature. Java allows platform
independence; therefore, the programs written in Java can be run on
multiple platforms with different operating systems. Java Virtual Machine
or JVM facilitates platform independence. When we need to run a written
program on a computer, we must convert it to machine code. Java uses an
interpreter and a compiler for this. Java allows automatic memory
management and this mechanism is referred to as garbage collection.
Because of garbage collection, the programmers should not write pieces of
codes saying from which objects to deallocate the memory.
At the end of this session you learnt to setup the Java Development
Environment, to compile a written program, to run a written program and to
check if Java is installed in your computer or not.

Learning Outcomes
Now you will be able to:
 identify the four main programming paradigms
 explain Object Oriented paradigm and the evolution of Object
Oriented Programming languages
 list Object Oriented Programming languages and their integrated
development platforms
 distinguish a compiler and an interpreter
11
Session 1 : Overview of Object Oriented Programming

 explain the use of a Java Virtual Machine (JVM)


 describe how Just-In-Time (JIT) compiler improved the
performance of the Java Virtual Machine(JVM)
 establish the programming environment to write Java programs

Review Questions
1) When programming languages were first introduced, they were known
as low level languages. What are low level languages and compare them
with current high level languages. What are their advantages and
disadvantages?

2) Why is it necessary to compile or interpret source codes written in high


level languages? What are the differences between the two methods?

3) Imagine you are a developer in 1960s and you have been ask to
automate an accounting department of an organization. What type of
programming you would select for this purpose? Give example of such
language.

4) Java is a full object oriented language. Do you agree with this


statement? Justify your answer.

5) The invention of C language was a turning point in the history of


programming. Many new languages were introduced after C. Give your
comments and observations.

6) Where do language like javascript, VB script, PHP, Python and etc fall
in the spectrum of programming languages.

7) Another model in today’s programming context is the Event driven


programming model. Why this model does have a wider popularity in
today’s programming community?

8) What are the programming languages you can use for AI applications?

9) In your opinion where you think we will be in five years’ time in future
with respect to programming languages?

12

You might also like