Object-Oriented Programming OOP John Gilligan School of Computing DIT Kevin St.

Slides:



Advertisements
Similar presentations
Agenda Definitions Evolution of Programming Languages and Personal Computers The C Language.
Advertisements

Programming Paradigms and languages
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
ISBN Chapter 3 Describing Syntax and Semantics.
CS 355 – Programming Languages
Classes & Objects Computer Science I Last updated 9/30/10.
Object-Oriented Analysis and Design
Object Oriented Programming A brief review of what you should know about OOP.
Overview of Programming Paradigms
Object Oriented System Development with VB .NET
1 ) Definition 2) Note on structured and modular programming, and information hiding 3) Example imperative languages 4) Features of imperative languages.
High-Level Programming Languages
Computers: Tools for an Information Age
Chapter 8 High-Level Programming Languages Nell Dale John Lewis.
Describing Syntax and Semantics
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
Chapter 1 Program Design
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 8: Introduction to High-Level Language Programming Invitation to Computer Science, C++ Version, Fourth Edition.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Python Introduction.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Programming languages Zuzana Brťková. What is programming language? A programming language is an artificial language designed to communicate instructions.
Programming Languages – Coding schemes used to write both systems and application software A programming language is an abstraction mechanism. It enables.
Programming Languages: Telling the Computers What to Do Chapter 16.
Programming Languages CPS120: Introduction to Computer Science Lecture 5.
OOP- OBJECT OBJECT PROGRAMMING By KRATI SHARMA 02 XI-B ✏✏✏✏ ☺☻☺☻☺☻☺ ✏✏✏✏
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
Introduction to Object-oriented programming and software development Lecture 1.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
Welcome to OBJECT ORIENTED PROGRAMMIN Date: 10/09/2014 Prepared By Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand.
UNIVERSITI TENAGA NASIONAL “Generates Professionals” CHAPTER 4 : Part 2 INTRODUCTION TO SOFTWARE DEVELOPMENT: PROGRAMMING & LANGUAGES.
BIT 1003 – Presentation 7. Contents GENERATIONS OF LANGUAGES COMPILERS AND INTERPRETERS VIRTUAL MACHINES OBJECT-ORIENTED PROGRAMMING SCRIPTING LANGUAGES.
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
Introduction To System Analysis and Design
1 Programming Language History and Evolution In Text: Chapter 2.
Computer Concepts 2014 Chapter 12 Computer Programming.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
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.
Principles of Software Development 1 Principles Of Software Design and Development Types of language / Choosing a language.
CS 345: Programming Language Paradigms Chris Brooks HR 510 MWF 11:00-12:05.
Module 4 Part 2 Introduction To Software Development : Programming & Languages Introduction To Software Development : Programming & Languages.
Programming Language 1. Programming language A programming language is a machine-readable artificial language designed to express computations that can.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Semantics In Text: Chapter 3.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Introduction to OOP CPS235: Introduction.
Akshata A. Naik Roll No: 11 B.L.I.Sc ( ) Assignment 1
Welcome to OBJECT ORIENTED PROGRAMMING Prepared By Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
PROGRAMMING (1) LECTURE # 1 Programming and Languages: Telling the Computer What to Do.
Programming Language History and Evolution
Programming Languages 2nd edition Tucker and Noonan
Programming paradigms
Visit for more Learning Resources
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
NOCTI Study Guide #2.
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Types of Programming Languages
Programming Language History and Evolution
Computer Programming.
Ada – 1983 History’s largest design effort
Programming Languages
High Level Programming Languages
Overview of Programming Paradigms
Programming Languages and Paradigms
Presentation transcript:

Object-Oriented Programming OOP John Gilligan School of Computing DIT Kevin St

What is a program? l “A program is a text which evokes computation” l Edsgar Dijkstra As we will see there are many kinds and styles of program.

What does it mean to evoke computation? l Well there is a program and something is computed when the program is executed. l Ideally the computation should achieve something that we want when the program is run. The executed program should meet our requirements. l There may be an informal or formal specification of these requirements

Clearly there is a relationship between specification and program Spec Program

From Specification to Program l Different Approaches to Programming vary in how they consider this relationship. l Typically the specification describes the problem in terms of inputs and outputs. l That is the input conditions or preconditions describe conditions or the state that holds now l The output conditions or postcondition describes the desired conditions or result that will hold after the problem has been solved or the program executed.

Verification l The program must be able to match the specification, that is do what its supposed to. l To prove that it does, it must be shown that the output state is reachable from the input state given the program. l This is called program verification.

There are many ways of developing programs l Traditional programming, called imperative programming, produces a sequence of statements which bring you from input to output conditions. l There are many formal verification techniques such as Dijkstras weakest precondition semantics. l Imperative programs tell you how to achieve a solution. They implement an algorithm.i.e. a sequence of steps which yield a solution.

Declarative Programming l The major alternative to imperative programming is declarative programming which says what is to be done not how to do it. l Examples of declarative programming include functional and logic programming such as Prolog. l In logic programming computation is produced as a by-product of proving that the output can be derived from the input. l In a pure functional language, such as Haskell, all functions are without side effects, and no explicit state or state changes exist at all.

So how does Object Oriented Programming fit into this l Object-oriented programming (OOP) is a programming paradigm that uses "objects" and their interactions to design applications and computer programs. l Programming techniques may include features such as encapsulation, modularity, polymorphism, and inheritance. l Many modern programming languages now support OOP.

Imperative Versus OOP l The big 2 approaches to Programming are Imperative and Object Oriented l Let us look at these in more detail.

History of Imperative programming l The earliest imperative languages were the machine languages of the original computers. l FORTRAN was a compiled language that allowed named variables, complex expressions, subprograms, and many other features now common in imperative languages. l In the late 1950s and 1960s, ALGOL was developed in order to allow mathematical algorithms to be more easily expressed, and even served as the operating system's target language for some computers. l COBOL (1960) and BASIC (1964) were both attempts to make programming syntax look more like English. l In the 1970s, Pascal was developed by Niklaus Wirth l C was created by Dennis Ritchie while he was working at Bell Laboratories. Wirth went on to design Modula-2, and Oberon.

Features of Imperative Languages l Variables and Constant Declarations l Assignment Statements l If Statements l Loops l Arrays

Example of imperative program piece l int is_leap_year(int year) { int result; if ( (year%4) != 0 ) // or: if ( year%4 ) result = FALSE; // means: if year is not divisible by 4 else if ( (year%400) == 0 ) // or: if ( !(year%400) ) result = TRUE; // means: if year is divisible by 400 else if ( (year%100) == 0 ) // or: if ( !(year%100) ) result = FALSE; // means: if year is divisible by 100 else // (but not by 400, since that case result = TRUE; // considered already) return ( result ); }

And another l m_fMin = 10000; m_fMax = 0; l int i; for ( i = 0; i < ARRAY_SIZE; i++ ) { m_fResultArray[i] = sqrt(m_fInitialArray[i] * 2.8f); if ( m_fResultArray[i] < m_fMin ) m_fMin = m_fResultArray[i]; if ( m_fResultArray[i] > m_fMax ) m_fMax = m_fResultArray[i]; }}

Advantages of Imperative Programming l Works l Follows intuitive algorithmic reasoning l Can be made modular l Can be documented l Good proof techniques l Widely accepted

Disadvantages of imperative programming l Can be messy l Poor for re-use l Data types buried in code (millenium Bug) l Arbitrary variable names l Allows bad programmers to have long unwieldy programs l Maintenance a high cost

As an Alternative l Consider Object Oriented Programming l The term “object-oriented” was coined by Alan Kay in 1967

Roots l Object-oriented programming can trace its roots to the 1960s. l As hardware and software became increasingly complex, quality was often compromised. l Researchers studied ways in which software quality could be maintained. Object-oriented programming was deployed in part as an attempt to address this problem by strongly emphasizing discrete units of programming logic and re-usability in software. l Computer programming methodology focuses on data rather than processes, with programs composed of self- sufficient modules (objects) containing all the information needed within its own data structure for manipulation.

OOP l Object-oriented programming may be seen as a collection of cooperating objects, as opposed to a traditional view in which a program may be seen as a group of tasks to compute ("subroutines"). In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects. l Each object can be viewed as an independent little machine with a distinct role or responsibility. The actions or "operators" on the objects are closely associated with the object. l For example, in object oriented programming, the data structures tend to carry their own operators around with them (or at least "inherit" them from a similar object or "class"). The traditional approach tends to view and consider data and behavior separately.

At First l The Simula programming language was the first to introduce the concepts underlying object-oriented programming (objects, classes, subclasses, virtual methods, coroutines, garbage collection, and discrete event simulation) as a superset of Algol. Simula was used for physical modeling, such as models to study and improve the movement of ships and their content through cargo ports. Smalltalk was the first programming language to be called "object-oriented".

History l The 1980s saw a rapid growth in interest in object-oriented programming. l These languages were imperative in style, but added features to support objects. l The last two decades of the 20th century saw the development of a considerable number of such programming languages. l Smalltalk, originally conceived by Alan Kay in 1969, was released in 1980 by the Xerox Palo Alto Research Center. l Drawing from concepts in another object-oriented language — Simula (which is considered to be the world's first object-oriented programming language, developed in the late 1960s) — Bjarne Stroustrup designed C++, an object-oriented language based on C. C++was first implemented in l In the late 1980s and 1990s, the notable imperative languages drawing on object- oriented concepts were Perl, released by Larry Wall in 1987; Python, released by Guido van Rossum in 1990; PHP, released by Rasmus Lerdorf in 1994; Java, first released by Sun Microsystems in 1994 and Ruby, released in 1995 by Yukihiro “matz” Matsumoto.

JAVA l In the past decade Java has emerged in wide use partially because of its similarity to C and to C++, but perhaps more importantly because of its implementation using a virtual machine that is intended to run code unchanged on many different platforms.C