Introduction to Object-Oriented Programming (OOP)

Slides:



Advertisements
Similar presentations
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Advertisements

Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
C++ Programming Languages
PZ05A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ05A - Abstract data types Programming Language Design.
CS 101 Course Summary December 5, Big Ideas Abstraction Problem solving Fundamentals of programming.
1 Lecture 24 Abstract Data Types (ADT) –I Overview  What is an Abstract Data type?  What is Stack ADT?  Stack ADT Specifications  Array Implementation.
Review 4 View classes as modules –Encapsulate operations –functions are static methods 4 View classes as struct types –Encapsulate data class C {...} C.
Object-oriented Programming Concepts
Presented by Neng-Fa Zhou1 Evolution of programming languages –Machine language –Assembly language –Sub-routines and loop (Fortran) –Procedures and recursion.
Lecture 9 Concepts of Programming Languages
1 Introduction to C++ Programming Concept Basic C++ C++ Extension from C.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
Object Oriented Programming
C ++ Programming Languages Omid Jafarinezhad Lecturer: Omid Jafarinezhad Fall 2013 Lecture 2 C ++ -overview Department of Computer Engineering 1.
Computer Science and Software Engineering behind Blogging platforms and software Team ASU 101 for CS/CSE students.
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
History of Programming Languages
Cs784(Prasad)L123Assg1 Assignments. cs784(Prasad)L123Assg2 l-value vs. r-value Pascal/Ada: x := x + 1 C/Java: x = x + 1 l-value = location, address, reference,
Chapter 24 Introduction to Object DBMSs Prepared by Kai Huang CS157B Prof Sin-Min Lee.
CSCI-383 Object-Oriented Programming & Design Lecture 4.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Chapter 3 Introduction to Collections – Stacks Modified
By Neng-Fa Zhou1 Evolution of programming languages –Machine language –Assembly language –Sub-routines and loop (Fortran) –Procedures and recursion (Algol,
1 Programming Language History and Evolution In Text: Chapter 2.
Computer Concepts 2014 Chapter 12 Computer Programming.
Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer.
1 COMP313A Programming Languages Object Oriented Progamming Languages (3)
30 May Stacks (5.1) CSE 2011 Winter Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An.
Programming Language 1. Programming language A programming language is a machine-readable artificial language designed to express computations that can.
1 Abstract Data Types & Object Orientation Abstract Data Types (ADT) Concepts –Data Abstraction –ADT in PLs –Encapsulation Object Orientation –Principal.
The History of Computer Programming Languages Introductory Programming Visual Basic.
Chapter 10, Slide 1 ABSTRACT DATA TYPES Based on the fundamental concept of ABSTRACTION:  process abstraction  data abstraction Both provide:  information.
Salman Marvasti Sharif University of Technology Winter 2015.
(1) ICS 313: Programming Language Theory Chapter 11: Abstract Data Types (Data Abstraction)
Copyright 2006 Oxford Consulting, Ltd1 January Introduction to C++ Programming is taking A problem Find the area of a rectangle A set of data.
int k = Integer.MAX_VALUE; k++; int k = Integer.MAX_VALUE; k++; What happens when the following code executes? byte b = someFile.readByte(); b = (byte)(b.
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
1-1 1 Introduction  Programming linguistics: concepts and paradigms syntax, semantics, and pragmatics language processors.  Historical development of.
Introduction to Objects and Encapsulation Computer Science 4 Mr. Gerb Reference: Objective: Understand Encapsulation and abstract data types.
A Short History of PL's (MacLennan 1999) “Zeroth Generation” (1940's-50's): machine language / assembly: if/then, read/write, store, goto
1 n Object Oriented Programming. 2 Introduction n procedure-oriented programming consists of writing a list of instructions and organizing these instructions.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Object Oriented Programming in Java Habib Rostami Lecture 2.
CPS120 Introduction to Computer Science High Level Language: Paradigms.
Abstract data types Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Programming Language History and Evolution
Object-Oriented Programming
Sections 3.4 Formal Specification
Why study programming languages?
Abstract Data Types and Encapsulation Concepts
ABSTRACT DATA TYPES Based on the fundamental concept of ABSTRACTION:
Stacks.
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Programming Language History and Evolution
Evolution of programming languages
Introduction to programming languages, Algorithms & flowcharts
Lecture 9 Concepts of Programming Languages
Stacks.
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Object-Oriented Programming
PZ05A - Abstract data types
Programming Language Design
Abstract data types Programming Language Design and Implementation
Object-Oriented Programming
Abstract data types Programming Language Design and Implementation
Programming Languages and Paradigms
Abstract data types Programming Language Design and Implementation
Lecture 9 Concepts of Programming Languages
Presentation transcript:

Introduction to Object-Oriented Programming (OOP) History Machine language Assembly language Sub-routines and loop (Fortran) Procedures and recursion (Algol, Pascal, C) Modules (Modula-2, Ada) Objects (Simula, Smalltalk, C++,Java)

Why OOP? What are the problems? Not generic Fixed size int stack[100]; int top; void init(){ top = -1; } void push(int val){ if (!isFull()){ stack[++top] = val; else error(“stack is full”); ... What are the problems? Not generic What happens if more stacks are needed? What happens if a stack of a different type is needed? Fixed size No effective information hiding mechanism

Why OOP? What are the problems? Still not generic Fixed size #define MAX 100 typedef struct { int top; int val[MAX]; } STACK; typedef STACK *STACK_PTR; void init(STACK_PTR sp); void push(STACK_PTR sp, int x); int pop(STACK_PTR sp); int isEmpty(STACK_PTR sp); int isFull(STACK_PTR sp); What are the problems? Still not generic What happens if a stack of another type is needed? Fixed size No effective information hiding or data protection

Abstract Data Types (ADT) ADT = (V,O) V: a set of values O: a set of operators Information hiding Encapsulation Modularity

Stack is an ADT class Stack { private LinkedList elms; public Stack() { elms = new LinkedList(); } public void push(Object x) { elms.addFirst(x); public Object pop() { if (isEmpty()){ throw new RuntimeException("Stack underflow"); } else return elms.removeFirst(); public boolean isEmpty() { return elms.size()==0;

Elements of OOP OOP Programming Classes Provides abstractions of both operations and data Classes A class specifies an abstract data type A class can be defined based on others (inheritance) A class defines the variables and behavior common to all objects of a certain kind

Elements of OOP Objects Methods An object has its own state An object’s behavior is determined by its class Methods Operations on objects

Elements of OOP Messages Objects perform computation by sending messages to each other message: receiver method name parameters return value SENDER RECEIVER

Elements of OOP Receivers Messages differ from traditional procedural calls in two very important aspects: In a message there is a designated receiver that accepts the message The interpretation of the message may be different, depending upon the receiver

Elements of OOP -- Recursive Design Every object has its own memory, which stores other objects

Inheritance super-class ParkingMeter subclass or extended class DigitalParkingMeter AnalogParkingMeter

Elements of OOP--Overriding Subclasses can alter or override information inherited from super-classes Bird NotFlyingBird Penguin

Why is OOP popular? Hope that it will quickly and easily lead to increased productivity and improved reliability (solve the software crisis) Hope for easy transition from existing languages Mimic problem solving in real worlds

Java is not Cure-all Database Artificial intelligence CGI Database programming languages Artificial intelligence Lisp, Prolog, Constraint languages CGI Perl, Java script, TCL Many other domain-specific languages