CSC- 210
Object Oriented Programming
LECTURE 1
PROGRAM DESIGN
TECHNIQUES
&
INTRODUCTION TO JAVA
OUTLINE
•
Program design techniques
•
Programming Overview
•
Programming Techniques
•
Problem Solving Steps
•
Introduction to Java
•
Anatomy of Java
PROGRAM DESIGN TECHNIQUES
Programming
Computer programming (often shortened to programming) is a process that leads from an original formulation of a computing problem to executable computer programs.
Programming Techniques / paradigms
paradigms
A programming paradigm can be understood as an abstraction of a computer system, for example the von Neumann model used in traditional sequential computers.
For parallel computing, there are many possible models typically reflecting different ways processors can be interconnected to
communicate and share information.
In object-oriented programming, programmers can think of a program as a collection of interacting objects, while in functional programming
a program can be thought of as a sequence of stateless function evaluations.
In process-oriented programming, programmers think about
EVOLUTIONS OF HIGH LEVEL
LANGUAGES
Programming languages have emerged as the powerful tools we use to describe algorithms for execution by
computers. Numerous
languages have been designed and implemented with varying goals and for different application areas. Evolution of high level
languages considers
Unstructured Programming Procedural Programming Emerged in 1970’s
e.g. C, Fortran
Modular Programming Emerged in 1980’s e.g. Turbo Pascal, Ada Object-Oriented Programming Emerged in 1990’s
e.g. C++, Java, .Net
Structured Programming
Blocks like “if, if else, switch, for” controlled the program flow
Emerged in
1960’s
e.g. Pascal, Ada
EVOLUTIONS OF HIGH LEVEL
LANGUAGES
UNSTRUCTURED STRUCTURED / PROCEDURAL
Main program directly operates on data Procedures, Methods or functions call each other
Data is always declared as global Data is handled in procedures or functions
Duplication of data and instructions occurs
Duplication of data and instructions don’t occurs
Whole logic is written in a single module
Logic is distributed into modules
Difficult to write a program Easy to write a program
Hard to understand and debug a program
Easy to understand and debug a program
UNSTRUCTURED STRUCTURED / PROCEDURAL
Examples:
Early versions of BASIC (such as MSX BASIC and GW-BASIC), JOSS, FOCAL,
MUMPS, TELCOMP, COBOL,
machine-level code, early assembler systems (without procedural metaoperators), assembler debuggers and some scripting languages such as MS-DOS batch file language
Examples:
C, Pascal, Ada, Fortran etc.
•
Procedures of a common
functionality are grouped
together
into
separate
modules.
•
The modules can be linked
together to complete a
whole task.
•
The
main
program
coordinates
calls
to
procedures
in
separate
modules.
•
No matter how well structured,
large programs
become
excessively complex
.
•
They allow unrestricted access to
global data
.
•
Attributes
and
behavior
are separated such that they poorly
model of the real world.
MODULAR PROGRAMMING
•
One of the most powerful and popular paradigms
•
Includes facilities for modular programming, and (in some sense)
procedural programming.
•
A program consists of a collection of cooperating objects rather
than a list of instructions (actions)
•
An object combines data structure and its related operations
together
OBJECT ORIENTED
•
Reduced cognitive load (have less to think about and more
natural paradigm)
•
Isolation of programmers (better team programming)
•
Less propagation of errors more adaptable/flexible programs
•
Faster development due to reuse of code
BENEFITS OF
Procedural (Structured)
Object-Oriented Programming
1 Algorithm is given importance. Data is given importance.
2 Can handle up to moderately complex programs.
Can handle very complex programs.
3 Flexibility is less. Flexibility is more.
4 Focus is on algorithm and control flow.
Focus is on object model.
5 Function call is used. Message passing is used.
6 Functions are independent of each other.
Each class is related in a hierarchical manner.
7 Less code reusability More code reusability
8 Less data security More data security
Procedural (Structured)
Object-Oriented Programming
10 Views data and functions as two separate entities.
Views data and functions as a single entity.
11 Program is divided into a number of sub modules or functions or procedures.
Program is organized by having a number of classes and objects.
12 Solution is solution-domain specific.
Solution is problem-domain specific.
13 The flow of execution of the
programming is dependent on the structure of the program.
The basic entity is object. Each
computation is performed using objects only.
•
Object programming was reported to exists in Simula 67 back in 1960s
•
Simula 67 is developed at the Norwegian Computing Center in Oslo, by
Ole-Johan Dahl and Kristen Nygaard.
•
Simula 67 is used to program Simulation
•
Influenced from Simula 67, later, the theory of OOP is introduced by
smallTalk (Xerox PARC) which further designed it to include the
pervasive use of objects and messages as the basis for computation.
•
Mid 1980s, OOP dominant the programming methodology through C++
(an extension of C Language)
•
More recently, a number of OOP languages exists
HISTORY OF
The promising areas for application of OOP includes:
1.Real time systems
2.
Simulation and modeling
3.
Object oriented databases
4.
Hypertext, hypermedia
5.
AI and expert systems
6.
Neural networks and parallel programming
7.
Decision support and office automation systems
8.
CIM/CAD systems
Object oriented technology is certainly changing the way
software engineers think, analyze, design and implement
systems today.
APPLICATIONS OF
•
Pure OO Languages
•
Smalltalk, Eiffel, Actor, Java, C#, Visual Basic
.NET
•
Hybrid OO Languages
•
C++, Objective-C, Object-Pascal
OOP
PROBLEM SOLVING USING
COMPUTER
1.
Analyze
the problem: Outline
solution requirements and design an
algorithm.
2.
Implement
the algorithm in a
programming language (Java) and
verify that the algorithm works.
3.
Maintain
the program: Use and
modify if the problem domain
changes.
PROBLEM SOLVING
PROBLEM SOLVING STEPS (Execution
PROGRAMMING
APPROACHES
STRUCTURED DESIGN OBJECT ORIENTED DESIGNProblem is divided into smaller sub problems
Program is a collection of interacting objects
Data and operations are at different places
Objects consist of data and operations
Steps in Structured Design:
1. Large problem divided into subroutines or subprograms
2. All subprograms are solved individually
3. Solved subprograms are integrated together
Steps in OOD:
1. 1. Identify objects
2. Form the basis of the solution
INTRODUCTION TO
•
James Gosling, Mike Sheridan, and Patrick Naughton
initiated the Java language project in June 1991
•
The language was initially called
Oak
after an oak tree that stood
outside Gosling's office
•
It went by the name
Green
later, and was later renamed
Java
,
from a list of random words
•
Gosling aimed to implement a virtual machine and a language
that had a familiar C/C++ style of notation
•
Sun Microsystems
released the first public implementation as
Java 1.0 in 1995
•
On May 8, 2007, Sun finished the process, making all of Java's
core code available under free software/open-source distribution
terms (
GNU Public License)
ORIGINS OF
1.
Java Standard Edition (Java
SE)
❖ For desktop, client/server application
2.
Java Enterprise Edition
(Java EE)
❖ For e-business, e-commerce web based application
3.
Java Micro Edition
(Java ME)
❖ For small devices, like palm, hand phone, etc
JAVA FAMILY
Version Name Code Name Release Date
JDK 1.0 Oak January 1996
JDK 1.1 (none) February 1997
J2SE 1.2 Playground December 1998
J2SE 1.3 Kestrel May 2000
J2SE 1.4 Merlin February 2002
J2SE 5.0 Tiger September 2004
Java SE 6 Mustang December 2006
Java SE 7 Dolphin July 2011
Java SE 8 (Not available) March 2014
The following table summarizes all versions of Java SE from its early
days to the latest.
JAVA
•
Simple
and familiar object oriented programming
•
Architecture neutral (
platform independent
)
•
Open Source
•
First rank in
TIOBE Index
•
De-Facto
standard programming language in
education
LEADS OF
Sep 2017 Sep 2016 Programming Language Ratings Change
1 1 Java 12.687% -5.55%
2 2 C 7.382% -3.57%
3 3 C++ 5.565% -1.09%
4 4 C# 4.779% -0.71%
5 5 Python 2.983% -1.32%
6 7 PHP 2.210% -0.64%
7 6 JavaScript 2.017% -0.91%
8 9 Visual Basic .NET 1.982% -0.36%
9 10 Perl 1.952% -0.38%
10 12 Ruby 1.933% -0.03%
11 18 R 1.816% +0.13%
12 11 Delphi/Object Pascal 1.782% -0.39%
13 13 Swift 1.765% -0.17%
14 17 Visual Basic 1.751% -0.01%
15 8 Assembly language 1.639% -0.78%
16 15 MATLAB 1.630% -0.20%
17 19 Go 1.567% -0.06%
18 14 Objective-C 1.509% -0.34%
19 20 PL/SQL 1.484% +0.04%
20 26 Scratch 1.376% +0.54%
1.
Compiler (Interpreter):
Java Standard Edition (JSE)
2.
Code Editor:
1.
Text Editor
:
TextPad, Notepad++
2.
Integrated Development Environment (IDE):
Netbeans, Eclipse, JCreator
JAVA PROGRAMMING
javac
(Java
Compiler)
java
(Java Interpreter)
JAVA
1.
Install Java SE by clicking:
jdk-8u20-windows-i586.exe
(download from:
http://www.oracle.com/technetwork/java/javase/downloads)
2.
Install Netbeans by clicking:
netbeans-8.0.-javase-windows.exe
(download from: http://netbeans.org/downloads)
Follow the entire installation process to complete
INSTALLATION
HelloWorld.java
public class Hello {
public static void main(String[] args) {
System.out.println("Hello World!"); }
}