0% found this document useful (0 votes)
73 views38 pages

Week 1 - Lecture 1

This document provides an overview of an advanced object-oriented programming course. The course expects students to have a background in programming and basic object-oriented concepts. The objective is to solidify OOP skills and study the Java programming language. Key topics covered include Java fundamentals, OOP concepts, graphical user interfaces, concurrency, and file handling. The lecture introduces procedural vs object-oriented programming and the history and components of the Java technology platform.

Uploaded by

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

Week 1 - Lecture 1

This document provides an overview of an advanced object-oriented programming course. The course expects students to have a background in programming and basic object-oriented concepts. The objective is to solidify OOP skills and study the Java programming language. Key topics covered include Java fundamentals, OOP concepts, graphical user interfaces, concurrency, and file handling. The lecture introduces procedural vs object-oriented programming and the history and components of the Java technology platform.

Uploaded by

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

Advanced Object Oriented Programming

Lec#1
Expected Background

 “A one-semester college course in programming.”

 I assume you can write a program in some language, understand variables,


control structures, functions/subroutines.

 Some basic knowledge of object oriented programming


Course Objective
 Solidify Object Oriented programming skills

 Study the Java Technology

 The Java Programming Language


My Policy on Cheating
 You may discuss homework problems with classmates, after you have made a
serious effort in trying the homework on your own.
 You can use ideas from the literature (with proper citation).
 You can use anything from the textbook/notes.
 The code you submit must be written completely by you, No sharing of code.
I give students a failing course grade for any cheating.
 This doesn’t help your job prospects.
Course Etiquette
 Etiquette is “conduct in polite society”

 No cell phones

 No random comings and goings

 Silence during lecture


Key Topics covered in this course

 Fundamentals of java programming


 Basic Concepts of Object Oriented Programming
 Graphical User Interface Programming
 Concurrency
 File Handling
Today’s Lecture
 Introduction to OOP
 Procedural Programming
 Object Oriented Programming
 History of java
 Java Technology
 The Java Programming Language
 Java Platform
 What is Programming?

 When we say “programming” we are actually referring to the science of transforming


our intentions in a high-level programming language.
Object-Oriented Programming
 Dominant programming paradigm these days
 A program is made of objects.
 Each object
 exposes specific functionality to the users
 encapsulates (hides) the implementation of its functionality
Traditional Procedural Programming
 1970s: “structured”, procedural programming
 Programs = Algorithms + Data ( Niklaus Wirth, 1975)
 First, we think about a set of procedures (algorithms) needed to solve our problem.
 Then, we find appropriate ways to store the data

 Used in C, Pascal, Basic, etc.


 Structured programming works well for small to medium sized problems
Procedural Programming
vs
Object Oriented Programming
Traditional Procedural Programming

Suppose that your program has 2,000


procedures

a piece of data is in an incorrect state

• How are you going to find bugs in


this situation?

• How many procedures you need to


search for the culprit?

In procedural programming, - problem is decomposed into


procedures - all procedures manipulate a set of global data
Object Oriented Programming
Suppose that …your program has 200 objects and each object
has 10 methods

a piece of data of an object is in an incorrect state

• How are you going to find bugs in this situation?

• How many procedures you need to search for


the culprit?

In object-oriented programming style, - your program consists of


objects - each object has a specific set of attributes and methods
Java History
 Java was created in 1991 by James Gosling in Sun Microsystems
 Initially called Oak
 in honor of the tree outside Gosling's window

 Its name was changed to Java


 because there was already a language called Oak.

 Sun Microsystems released the first public implementation as Java 1.0 in 1995
 Java syntax is similar to C and C++.
The Java technology is:
 A programming language
 Java can create all kinds of applications

 A development environment
 A compiler (javac)
 An interpreter (java)
 A documentation generator (javadoc)
 …

 Compare it to C++
C++ vs Java
Features Java C++
Data types Supports both primitive scalar types and Supports both primitive scalar
classes types and classes
Object Allocated from heap, accessed through Allocated form heap pr stack
Allocation reference variables ,accessed through reference
(no pointers) variables or pointers
Object de- Implicit (Garbage collection) Explicit (delete operator)
allocation

Inheritance Single inheritance only (multiple Single ,Multiple inheritance


inheritance is implemented with interfaces)

Binding All binding of messages to methods are Dynamic binding of methods are
dynamic except in the case of methods that optional (using virtual keyword)
cannot be overridden
Grarbage Collection

 Int * p = new int();


 *p=5;
 delete p; p 500
700
 p=new int(10); 500 5

700 10

Stack Heap
Java Technology
Key Tools for Programming
 Editors: Allows user to enter the program. Notepad etc are all editors.
 Compilers: Translates the program into target code .
 Debuggers: Allows a programmer to run the program to see the execution of the
program and correct any errors.
 Profilers: Used to evaluate program’s performance.
 Integrated Development Environment (IDE): Combines editor, compiler,
debugger and profiler or a subset into one tool.
 Common Java IDEs are Eclipse, Netbeans, BlueJ, and DrJava.
C++ Compilation Process
Java Compilation Process
Java ByteCode
 What is ByteCode?
 Also known as portable code, is a form of instruction set designed for efficient
execution by software interpreter.
Java Runtime Enviornment
Java Development Kit
Java Runtime Environment
JRE
Java Development Tools
To run Java Applications
e.g. Compiler, Debugger etc
Java Virtual
Java API Machine To develop Java
Classes JVM Applications

Operating System
(Windows, LINUX, ETC)

Hardware
(INTEL,AMD, ETC)
Java As a Programming
Platform

 A platform is the hardware or software environment in which a program runs.


 E.g. Windows, Linux, Solaris OS, and Mac OS

 Java is a software-only platform that runs on top of other hardware-based platforms. It


consists of
 The Java Virtual Machine: a software-based processor that presents its own instruction set
 The Java Application Programming Interface (API) : A large collection of ready-made software
components that provide many useful capabilities. It is grouped into libraries of related classes and
interfaces; these libraries are known as packages .
Java Software Development Process

 Write the source code and save in files with .java extension
 Compile the source code into .class files using the javac compiler
 A .class file contains bytecodes (the machine language of the
Java Virtual Machine i.e. Java VM)
 Run the application (with an instance of the Java VM) using the
java launcher tool.
Java Program Execution

 The java tool loads and starts the VM, and passes the program’s
main classfile (.class) to the machine
 The VM uses classloader to load the classfile
 The VM’s bytecode verifier checks that the classfile’s bytecode is
valid and does not compromise security
 If the bytecode has any problem, the verifier terminates the VM
 If all is well with the bytecode, the VM’s interpreter (JIT)
interprets the bytecode one instruction at a time
* Interpretation consists of identifying bytecode instructions , and executing equivalent
native instructions (instructions understood by the physical processor )
javac HelloWorldApp.java

Java HelloWorldApp
 HelloWorldApp
 (1)Load the JVM

•The Java platform provides an abstraction over the underlying hardware/OS platform
- Portability: the same .class files can run unchanged on a variety of hardware
platforms and operating systems
Java Technology
Java is Popular
 Some reports on programming languages popularity
 According to
 Job advertisements
 Book sales
 Finding code on the web
 …
https://codinginfinite.com/stack-overflow-developers-survey-2019-vs-2018-technology-comparison/
(2019)
Characteristics of the Java PL

 Simple  Architecture neutral


 Object oriented  Portable
 Distributed  High Performance
 Multithreaded  Robust
 Dynamic  Secure
First Java Program

class First
{
public static void main(String arg[])
{
System.out.println("Engr. Farrah Aslam welcomes you in AOOP Course");
}
}
Reference Book
 Books
 Java the complete reference by helbert schildt 7 th edition
 Java how to program, by deitel & deital 8 th edition
 Additional reference (reccomended)
 Head first java 2nd edition
Goal of the course???
Acknowledgments
 Preparing this lecture , I have greatly benefitted from the work of
 Peyman Dodangeh, Sharif University of Technology
 Andy Van Dam (Brown University)
 Mark Sheldon (Wellesley College)
 Robert Sedgewick and Kevin Wayne (Princeton University)

You might also like