List of lectures. Lecture content. Lecture goal. Object Oriented Programming. Object-oriented and type. TDDA69 Data and Program Structure
|
|
- Lucas Shaw
- 5 years ago
- Views:
Transcription
1 List of lectures TDDA69 Data and Program Structure Object Oriented Programming and type system Cyrille Berger 1 Introduction and Functional Programming 2 Imperative Programming and Data Structures 3 Environment 4 Evaluation 5 Object Oriented Programming and type system 6 Macros and 7 Virtual Machines and Bytecode 8 Garbage Collection and Native Code 9 Distributed Computing 10 Logic 11 Guest lecture 12 Summary 2 / 54 Lecture goal Object-oriented and type concepts and conscequence for program interpretation Lecture content Object Oriented Programming Object-Oriented Concepts Implementation Revisiting the visitor pattern Exceptions Type 3 / 54 4 / 54
2 Program Organizing Techniques Non-structured Programming Object Oriented Programming Structured Programming Modular Programming Object-Oriented Programming 6 Non-structured Programming The main program directly operates on globa data Program main program / data Impractical when the program gets sufficiently large The same statement sequence must be copied if it is needed several times Procedural Programming Combine a sequence of statements into a procedure with calls and returns The main program coordinates calls to procedures and hands over appropriate data as Program main program / data Procedure 1 Procedure 2 Procedure 3 Tasks are a collection of states, structures and procedures 7 8
3 Modular Programming Procedures of a common functionality are grouped together into separate modules. The main program coordinates calls to procedures in separate modules and hands over data as parameters. Program Module 1 data + data 1 Procedure 1 Procedure 2 main program / data Module 2 data + data 2 Procedure 3 Limitations of Structured and Modular Programming Unrestricted access to global Global data 1 Global data 2 Global data 3 Procedure 1 Procedure 2 Procedure 3 Procedure 4 Attributes and behaviors are seperated Not 9 10 What is Object-Oriented Programming? Object-Oriented Concepts A modeling technique It is a natural technique The world is made of objects: house, tree, car, computer... Allow to describe a program before it is written 12
4 What is an Object? Real-world objects are composed of attributes and behaviors Attributes: color, size,... Behaviors: accelerate, brake,... Program Attributes are states/variables Behaviors are functions Object-Oriented Concepts Class Inheritance Encapsulation Polymorphism Class An object is a specific instance (ie this car, this computer...) A class is a type of object (ie a car, a computer...) It is a blueprint of object The class defines: The default set of variables The default set of functions An initialisation function (called constructor The object is an instance of a class It points to a specific memory location with the actual values for variables Class Car class Car: attributes: color can be red, green, blue... speed from 0 to max_speed max_speed and max_acceleration are constant functions: accelerate increase speed with max_acceleration brake decrease speed with max_acceleration object: red_audi := { color:'red', max_speed: 200, max_acceleration: 10 blue_volvo := { color:'blue', max_speed: 180, max_acceleration:
5 Inheritance Some classes have common part Audi is a car, Volvo is a car, but Volvo and Audi are two different type of cars Inheritance allows to define a class in term of an other super-class Sub-classes can add new variables and functions override variables and functions from the super-class Inheritance from the class Car class Car: color, speed, max_speed and max_acceleration class Audi: class Car with max_speed := 200 and max_acceleration := 10 class Volvo: class Car with max_speed := 180 and max_acceleration := Encapsulation Encapsulation is the ability to hide variables Three common levels of Private: only accessible to the object Protected: only accessible to the object and through inheritance Public: accessible to the world Polymorphism polymorphism is the ability to appear in many forms It is the ability to call a function on an object that will execute different code for different objects For example, a shape class with an area function and triangle, square... It is one way of creating generic code 19 20
6 The advantages of Object-Oriented Programming Code reusability Code can shared in the superclass Polymorphism allow to define interfaces Inheritence clarifies the relationship among program elements Encapsulation allow modularity and control on access to variables 21 Implementation Implementing Object-Oriented Programming Defining members: variables (Almost) any imperative programming language can be made to support object-oriented programming For instance, first C++ compiler was compiling to C and many object systems have been added to C All you need is a In JavaScript/ obj = { value: 1.0, name: 'some object' console.log(obj.value) console.log(obj['value']) In class Test def init (self): self.value = 1.0 self.name = 'some object' obj = Test() print(obj.value) console.log(obj. dict ['value']) 23 24
7 Defining members: functions Allmost all you need is to save obj = { value: 1.0, dosomething: function() { return 42; But how to access the variables You either need to pass a pointer to the object Implicitely, like in JavaScript/ECMAScript: obj = { value: 1.0, getvalue: function() { return this.value; Explicitely, like in Python: class Test def init (self): self.value = 1.0 def getvalue(self): return self.value What about classes? With dictionnary we have objects For a class, all we need is a constructor function create_car(self, color, max_speed, max_acceleration): self.color = color self.speed = 0.0 self.max_speed = max_speed self.max_acceleration = max_acceleration self.accelerate = function() { self.speed = Math.min(self.max_speed, self.speed + self.max_acceleration) self.decelerate = function() { self.speed = Math.max(0, self.speed - self.max_acceleration) For inheritance, all we need is to call the super class constructor function create_audi(self, color): create_audi(self, color, 200, 10) Class in JavaScript/ECMAScript What about encapsulation? function Car(color, max_speed, max_acceleration) { this.color = color... Car.prototype.accelerate = function() { self.speed = Math.min(self.max_speed, self.speed + self.max_acceleration) Car.prototype.decelerate =... function Audi(color) { Car.call(color, 200, 10) Audi.prototype = Object.create(Car.prototype) red_audi = new Audi('red') red_audi.accelerate() (Ab)using environment function Car(color, max_speed, max_acceleration) { this.getcolor = function() { return color... And for protected function Car(color, max_speed, max_acceleration, protected = {) { protected.color = color... function Audi(color) { var protected = { Car.call(color, 200, 10, protected) this.getcolor = function() { return protected.color Audi.prototype = Object.create(Car.prototype) 27 28
8 What about polymorphism? Just overwrite function in the child class function Shape() { this.area = function() { throw 'Error'; function Square(width, height) { Shape.call(this) this.area = function() { return width * height Square.prototype = Object.create(Shape.prototype) Revisiting the visitor pattern 29 Object-Oriented Abstract Syntax Tree An Value class class Value: def init (self, value): self.value = value An Operator class class Operator: def init (self, a, b): self.a = a self.b = b An addition class class Addition(Operator): def init (self, a, b): super(). init (a, b)... Example ['+' [1 ['*' [4 ['/' [5 ['+' [ 2 3 ] ]]]]]]] Addition.new(1, Multiplication.new(4, Division.new(5, Addition.new(2, 3)))) 31 32
9 Visitor Oriented Object visitor (1/2) def evaluate(node): if not isinstance(node, list): return node elif node[0] == '+': return evaluate(node[1][0]) + evaluate(node[1][1]) elif node[0] == '-': return evaluate(node[1][0]) - evaluate(node[1][1]) elif node[0] == '*': return evaluate(node[1][0]) * evaluate(node[1][1]) elif array[0] == '/': return evaluate(node[1][0]) / evaluate(node[1][1]) else: raise Error() def evaluate(node): if isinstance(node, Value): return node.value elif isinstance(node, Addition): return evaluate(node.a) + evaluate(node.b) elif isinstance(node, Substraction): return evaluate(node.a) - evaluate(node.b) elif isinstance(node, Multiplication): return evaluate(node.a) * evaluate(node.b) elif isinstance(node, Division): return evaluate(node.a) / evaluate(node.b) else: raise Error() class Visitor: def visitvalue(self, node): return node.value def visitaddition(self, node): return node.a.accept(self) + node.b.accept(self) def visitsubstraction(self, node): return node.a.accept(self) - node.b.accept(self) def visitmultiplication(self, node): return node.a.accept(self) * node.b.accept(self) def visitdivision(self, node): Oriented Object visitor (2/2) class Value:... def accept(self, visitor): return visitor.visitvalue(self) class Addition:... def accept(self, visitor): return visitor.visitaddition(self) Why use the visitor pattern at all? Easy way to extend For an interpreted: A visitor for evaluating A visitor to convert to a different programming language A visitor to generate bytecode
10 Software Exceptions Exceptions Exceptions are events that affect the control flow of a program. An exception allows to return from a function or a statment at any point, with any type and on any number of levels. Exception need to be caught. 38 Control flow and exceptions What are exceptions used for? try: a() rescue Exception: print('rescued') def a(): b() print('never called') def b(): throw Exception() 39 40
11 Exception for error handling Most common use of exception is for error handling More convenient than returning a value (which is not possible in a constructor) Exception for exiting a double loop try: for i in range(0, 10): for j in range(0, 40): if i*j == 300: throw Exception('double break') except: pass Break and return statement Using exception for break and return How to implement the 'break' and 'return' statement? WhileStatement.new(..., [... BreakStatement.new ]) Using a return value? class EvalVisitor: def visitbreakstatement(self, node): return false def visitwhilestatement(self, node): while(node.condition.accept(self)): if not visitchildren(node): break; return true def visitchildren(self, node): for(child in node.children): if(not child.accept(self) return false return true Very similar to error checking 43 Instead, lets use class EvalVisitor: def visitbreakstatement(self, node): throw BreakException() def visitwhilestatement(self, node): try: while(node.condition.accept(self)): visitchildren(node) rescue BreakException: pass def visitchildren(self, node): for(child in node.children): child.accept(self) 44
12 And how to implement exception in the interpreter? Using exceptions... class EvalVisitor: def visitthrowstatement(self, node): throw InterpretedException(node.exceptionType) def visittrycatchstatement(self, node): try: visitchildren(node.body) except InterpretedException as ie: if ie.type == node.exceptiontype: visitchildren(node.catch) else: throw ie Type system 45 What is a type system? Type-Checking A type system defines how a type is associated to a variable Variables are stored as bits in memory A type give meaning to a set of bits In a program, a value is associated to at least one type 47 Static-type checking Types are checked at compilation from static analysis Usually variables have a single type Polymorphism allows for dynamicity Support from downcasting Dynamic-type checking Types are checked at runtime The type of a variable can change Unchecked Example: machine code 48
13 Static-type checking Allow for optimization No need to check for types at runtime Program verification Can work better than unit-tests if(almost always true) { /* valid code */ else { /* type invalid code */ But downcasting cannot be verified with static checking Static-type vs Dynamic-type Trade-off The number of actual errors found through static typing is debatable Dynamic typing allows for faster development and faster compilation Implementing static-typing Implementing dynamic-typing With an AST visitor! Instead of returning a value, return a type class StaticTypeCheckerVisitor: def visitvalue(self, node): return node.type def checkarithmetic(self, typea, typeb): if(typea == typeb): return typea elif(typea.canconvert(typeb)): return typeb elif(typeb.canconvert(typea)): return typea else: throw CompilationError('Invalid types') def visitaddition(self, node): return self.checkarithmetic(node.a.accept(self), node.b.accept(self) def visitassignment(self, node): typevariable = environment.getvariable(node.variablename).type typevalue = node.value.accept(self) if(typevariable!= typevalue and!typevalue.canconvert(typevariable)): throw CompilationError('Invalid types') return typevariable class EvalVisitor: def doarithmetic(self, op, node): a = node.a.accept(self) b = node.b.accept(self) if(a.type == b.type): return op(a, b) elif(a.type.canconvert(b.type)): return op(a.convert(b.type), b) elif(b.type.canconvert(a.type)): return op(a, b.convert(a.type)) else: throw ExecutionError('Invalid types') def visitaddition(node): return self.doarithmetic(operators.add, node) 51 52
14 Strong vs Weak typing A language is said to be strongly typed when it requires explicitely casting Example: ADA A language is said to be weakly typed when it allows certins nonexplicit casting For instance, from integers to floating points Conclusion Object-oriented concept and how to implement them Improved pattern visitor Exceptions and how to use them in an interpreter The implication of a type / 54
List of lectures. Lecture content. Imperative Programming. TDDA69 Data and Program Structure Imperative Programming and Data Structures
List of lectures TDDA69 Data and Program Structure Imperative Programming and Data Structures Cyrille Berger 1Introduction and Functional Programming 2Imperative Programming and Data Structures 3Parsing
More informationChapter 5 Object-Oriented Programming
Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares
More informationLecture content. Course goals. Course Introduction. TDDA69 Data and Program Structure Introduction
Lecture content TDDA69 Data and Program Structure Introduction Cyrille Berger Course Introduction to the different Programming Paradigm The different programming paradigm Why different paradigms? Introduction
More informationArgument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.
Local Variable Initialization Unlike instance vars, local vars must be initialized before they can be used. Eg. void mymethod() { int foo = 42; int bar; bar = bar + 1; //compile error bar = 99; bar = bar
More informationCSE 431S Type Checking. Washington University Spring 2013
CSE 431S Type Checking Washington University Spring 2013 Type Checking When are types checked? Statically at compile time Compiler does type checking during compilation Ideally eliminate runtime checks
More informationTopic 9: Type Checking
Recommended Exercises and Readings Topic 9: Type Checking From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 13.17, 13.18, 13.19, 13.20, 13.21, 13.22 Readings: Chapter 13.5, 13.6 and
More informationTopic 9: Type Checking
Topic 9: Type Checking 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 13.17, 13.18, 13.19, 13.20, 13.21, 13.22 Readings: Chapter 13.5, 13.6
More informationCS-202 Introduction to Object Oriented Programming
CS-202 Introduction to Object Oriented Programming California State University, Los Angeles Computer Science Department Lecture III Inheritance and Polymorphism Introduction to Inheritance Introduction
More informationObject oriented programming. Encapsulation. Polymorphism. Inheritance OOP
OOP Object oriented programming Polymorphism Encapsulation Inheritance OOP Class concepts Classes can contain: Constants Delegates Events Fields Constructors Destructors Properties Methods Nested classes
More informationExample: Class MSDie Introduction to Graphs and NetworkX
Example: Class MSDie Introduction to Graphs and NetworkX Monday, March 30, 2009 1 Be careful whose random number generator you trust http://xkcd.com/221/ 2 1 Reminders Sample exam questions have been posted
More informationJAVA MOCK TEST JAVA MOCK TEST II
http://www.tutorialspoint.com JAVA MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Java Framework. You can download these sample mock tests at your
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
More informationLecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction
Lecture 13: Object orientation Object oriented programming Introduction, types of OO languages Key concepts: Encapsulation, Inheritance, Dynamic binding & polymorphism Other design issues Smalltalk OO
More informationObject-Oriented Programming (OOP) Fundamental Principles of OOP
Object-Oriented Programming (OOP) O b j e c t O r i e n t e d P r o g r a m m i n g 1 Object-oriented programming is the successor of procedural programming. The problem with procedural programming is
More informationCOMP200 INHERITANCE. OOP using Java, from slides by Shayan Javed
1 1 COMP200 INHERITANCE OOP using Java, from slides by Shayan Javed 2 Inheritance Derive new classes (subclass) from existing ones (superclass). Only the Object class (java.lang) has no superclass Every
More informationObject-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018
Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 1: Types and Control Flow http://courses.cs.cornell.edu/cs2110/2018su Lecture 1 Outline 2 Languages Overview Imperative
More informationS.No Question Blooms Level Course Outcome UNIT I. Programming Language Syntax and semantics
S.No Question Blooms Level Course Outcome UNIT I. Programming Language Syntax and semantics 1 What do you mean by axiomatic Knowledge C254.1 semantics? Give the weakest precondition for a sequence of statements.
More information2. The object-oriented paradigm!
2. The object-oriented paradigm! Plan for this section:! n Look at things we have to be able to do with a programming language! n Look at Java and how it is done there" Note: I will make a lot of use of
More informationCS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 17: Types and Type-Checking 25 Feb 08
CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 17: Types and Type-Checking 25 Feb 08 CS 412/413 Spring 2008 Introduction to Compilers 1 What Are Types? Types describe the values possibly
More informationJava: introduction to object-oriented features
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer
More informationObject Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia
Object Oriented Programming in Java Jaanus Pöial, PhD Tallinn, Estonia Motivation for Object Oriented Programming Decrease complexity (use layers of abstraction, interfaces, modularity,...) Reuse existing
More informationOBJECT ORİENTATİON ENCAPSULATİON
OBJECT ORİENTATİON Software development can be seen as a modeling activity. The first step in the software development is the modeling of the problem we are trying to solve and building the conceptual
More informationProgramming Languages Fall 2013
Programming Languages Fall 2013 Lecture 2: types Prof. Liang Huang huang@qc.cs.cuny.edu Recap of Lecture 1 functional programming vs. imperative programming basic Haskell syntax function definition lazy
More informationCS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE
CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE PART A UNIT I 1. Differentiate object oriented programming from procedure oriented programming. 2. Define abstraction and encapsulation. 3. Differentiate
More informationWeek 8 Lecture: Programming
Week 8 Lecture: Introduction to Object Oriented Programming Introduction to Programming for GIS & Remote Sensing GEO6938 1469 GEO4938 147A Objects: You ve Been Exposed! Modularization, you know about it
More informationOutline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring
Java Outline Java Models for variables Types and type checking, type safety Interpretation vs. compilation Reasoning about code CSCI 2600 Spring 2017 2 Java Java is a successor to a number of languages,
More informationContents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance
Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass
More informationIntroduction to Inheritance
Introduction to Inheritance James Brucker These slides cover only the basics of inheritance. What is Inheritance? One class incorporates all the attributes and behavior from another class -- it inherits
More informationObject-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018
Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 4: OO Principles - Polymorphism http://courses.cs.cornell.edu/cs2110/2018su Lecture 3 Recap 2 Good design principles.
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationObject typing and subtypes
CS 242 2012 Object typing and subtypes Reading Chapter 10, section 10.2.3 Chapter 11, sections 11.3.2 and 11.7 Chapter 12, section 12.4 Chapter 13, section 13.3 Subtyping and Inheritance Interface The
More informationObject Fundamentals. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 2 08/30/2007
Object Fundamentals Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 2 08/30/2007 1 Lecture Goals Introduce basic concepts, terminology, and notations for object-oriented analysis,
More information1 Shyam sir JAVA Notes
1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write
More informationCMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are "built" on top of that.
CMSC131 Inheritance Object When we talked about Object, I mentioned that all Java classes are "built" on top of that. This came up when talking about the Java standard equals operator: boolean equals(object
More informationOBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak
OBJECT ORIENTED PROGRAMMING Ms. Ajeta Nandal C.R.Polytechnic,Rohtak OBJECT ORIENTED PARADIGM Object 2 Object 1 Data Data Function Function Object 3 Data Function 2 WHAT IS A MODEL? A model is an abstraction
More informationG Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University
G22.2110-001 Programming Languages Spring 2010 Lecture 6 Robert Grimm, New York University 1 Review Last week Function Languages Lambda Calculus SCHEME review 2 Outline Promises, promises, promises Types,
More informationOverview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017
Overview of OOP Dr. Zhang COSC 1436 Summer, 2017 7/18/2017 Review Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in square brackets: l = [1, 2, "a"] (access by index, is mutable
More informationVALLIAMMAI ENGINEERING COLLEGE
VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 603 203 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK B.E. - Electrical and Electronics Engineering IV SEMESTER CS6456 - OBJECT ORIENTED
More informationCOMP519 Web Programming Lecture 21: Python (Part 5) Handouts
COMP519 Web Programming Lecture 21: Python (Part 5) Handouts Ullrich Hustadt Department of Computer Science School of Electrical Engineering, Electronics, and Computer Science University of Liverpool Functions
More informationPaytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value
Paytm Programming Sample paper: 1) A copy constructor is called a. when an object is returned by value b. when an object is passed by value as an argument c. when compiler generates a temporary object
More informationAgenda. Objects and classes Encapsulation and information hiding Documentation Packages
Preliminaries II 1 Agenda Objects and classes Encapsulation and information hiding Documentation Packages Inheritance Polymorphism Implementation of inheritance in Java Abstract classes Interfaces Generics
More informationCME 193: Introduction to Scientific Python Lecture 6: Classes and iterators
CME 193: Introduction to Scientific Python Lecture 6: Classes and iterators Sven Schmit stanford.edu/~schmit/cme193 6: Classes and iterators 6-1 Contents Classes Generators and Iterators Exercises 6: Classes
More informationGIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes
GIS 4653/5653: Spatial Programming and GIS More Python: Statements, Types, Functions, Modules, Classes Statement Syntax The if-elif-else statement Indentation and and colons are important Parentheses and
More informationCOP 3330 Final Exam Review
COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time
More informationInheritance, and Polymorphism.
Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to
More informationINHERITANCE & POLYMORPHISM. INTRODUCTION IB DP Computer science Standard Level ICS3U. INTRODUCTION IB DP Computer science Standard Level ICS3U
C A N A D I A N I N T E R N A T I O N A L S C H O O L O F H O N G K O N G INHERITANCE & POLYMORPHISM P2 LESSON 12 P2 LESSON 12.1 INTRODUCTION inheritance: OOP allows a programmer to define new classes
More informationObject Oriented Programming. Java-Lecture 11 Polymorphism
Object Oriented Programming Java-Lecture 11 Polymorphism Abstract Classes and Methods There will be a situation where you want to develop a design of a class which is common to many classes. Abstract class
More informationCPS 506 Comparative Programming Languages. Programming Language
CPS 506 Comparative Programming Languages Object-Oriented Oriented Programming Language Paradigm Introduction Topics Object-Oriented Programming Design Issues for Object-Oriented Oriented Languages Support
More informationLecture 27. Lecture 27: Regular Expressions and Python Identifiers
Lecture 27 Lecture 27: Regular Expressions and Python Identifiers Python Syntax Python syntax makes very few restrictions on the ways that we can name our variables, functions, and classes. Variables names
More informationCSCI-142 Exam 1 Review September 25, 2016 Presented by the RIT Computer Science Community
CSCI-12 Exam 1 Review September 25, 2016 Presented by the RIT Computer Science Community http://csc.cs.rit.edu 1. Provide a detailed explanation of what the following code does: 1 public boolean checkstring
More informationJava Primer. CITS2200 Data Structures and Algorithms. Topic 2
CITS2200 Data Structures and Algorithms Topic 2 Java Primer Review of Java basics Primitive vs Reference Types Classes and Objects Class Hierarchies Interfaces Exceptions Reading: Lambert and Osborne,
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 20, 2014 Abstract
More informationObject-Oriented Programming
Object-Oriented Programming 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Object-Oriented
More informationSpecial Topics: Programming Languages
Lecture #23 0 V22.0490.001 Special Topics: Programming Languages B. Mishra New York University. Lecture # 23 Lecture #23 1 Slide 1 Java: History Spring 1990 April 1991: Naughton, Gosling and Sheridan (
More informationInheritance -- Introduction
Inheritance -- Introduction Another fundamental object-oriented technique is called inheritance, which, when used correctly, supports reuse and enhances software designs Chapter 8 focuses on: the concept
More informationFundamentals of Object Oriented Programming
INDIAN INSTITUTE OF TECHNOLOGY ROORKEE Fundamentals of Object Oriented Programming CSN- 103 Dr. R. Balasubramanian Associate Professor Department of Computer Science and Engineering Indian Institute of
More informationChapter 14 Abstract Classes and Interfaces
Chapter 14 Abstract Classes and Interfaces 1 What is abstract class? Abstract class is just like other class, but it marks with abstract keyword. In abstract class, methods that we want to be overridden
More informationDesign Pattern and Software Architecture: IV. Design Pattern
Design Pattern and Software Architecture: IV. Design Pattern AG Softwaretechnik Raum E 3.165 Tele.. 60-3321 hg@upb.de IV. Design Pattern IV.1 Introduction IV.2 Example: WYSIWYG Editor Lexi IV.3 Creational
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 21, 2013 Abstract
More informationCREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed
CREATED BY: Muhammad Bilal Arslan Ahmad Shaad JAVA Chapter No 5 Instructor: Muhammad Naveed Muhammad Bilal Arslan Ahmad Shaad Chapter No 5 Object Oriented Programming Q: Explain subclass and inheritance?
More informationData Structures (list, dictionary, tuples, sets, strings)
Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access
More informationIndex COPYRIGHTED MATERIAL
Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes
More informationData Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques. Version 03.s 2-1
Design Principles Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques 2-1 Data Structures Data Structure - A systematic way of organizing and accessing
More informationWhat are the characteristics of Object Oriented programming language?
What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is
More informationCS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70
CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 2012 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers
More informationObject-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 2: Review of Object Orientation
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 2: Review of Object Orientation 2.1 What is Object Orientation? Procedural paradigm: Software is organized
More informationMore C++ : Vectors, Classes, Inheritance, Templates
Vectors More C++ : Vectors,, Inheritance, Templates vectors in C++ basically arrays with enhancements indexed similarly contiguous memory some changes defined differently can be resized without explicit
More informationData Abstraction: The Walls
Chapter 4 Data Abstraction: The Walls 2011 Pearson Addison-Wesley. All rights reserved 4-1 Abstract Data Types Modularity Keeps the complexity of a large program manageable by systematically controlling
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationCS 162, Lecture 25: Exam II Review. 30 May 2018
CS 162, Lecture 25: Exam II Review 30 May 2018 True or False Pointers to a base class may be assigned the address of a derived class object. In C++ polymorphism is very difficult to achieve unless you
More informationIST311. Advanced Issues in OOP: Inheritance and Polymorphism
IST311 Advanced Issues in OOP: Inheritance and Polymorphism IST311/602 Cleveland State University Prof. Victor Matos Adapted from: Introduction to Java Programming: Comprehensive Version, Eighth Edition
More informationInheritance and Interfaces
Inheritance and Interfaces Object Orientated Programming in Java Benjamin Kenwright Outline Review What is Inheritance? Why we need Inheritance? Syntax, Formatting,.. What is an Interface? Today s Practical
More informationCMSC201 Computer Science I for Majors
CMSC201 Computer Science I for Majors Lecture 25 Classes All materials copyright UMBC and Dr. Katherine Gibson unless otherwise noted Run time Last Class We Covered Run time of different algorithms Selection,
More informationInheritance. SOTE notebook. November 06, n Unidirectional association. Inheritance ("extends") Use relationship
Inheritance 1..n Unidirectional association Inheritance ("extends") Use relationship Implementation ("implements") What is inherited public, protected methods public, proteced attributes What is not inherited
More informationMore C++ : Vectors, Classes, Inheritance, Templates. with content from cplusplus.com, codeguru.com
More C++ : Vectors, Classes, Inheritance, Templates with content from cplusplus.com, codeguru.com 2 Vectors vectors in C++ basically arrays with enhancements indexed similarly contiguous memory some changes
More informationCSE 401/M501 Compilers
CSE 401/M501 Compilers Code Shape II Objects & Classes Hal Perkins Autumn 2018 UW CSE 401/M501 Autumn 2018 L-1 Administrivia Semantics/type check due next Thur. 11/15 How s it going? Reminder: if you want
More informationLearning the Java Language. 2.1 Object-Oriented Programming
Learning the Java Language 2.1 Object-Oriented Programming What is an Object? Real world is composed by different kind of objects: buildings, men, women, dogs, cars, etc. Each object has its own states
More informationCS558 Programming Languages Winter 2013 Lecture 8
OBJECT-ORIENTED PROGRAMMING CS558 Programming Languages Winter 2013 Lecture 8 Object-oriented programs are structured in terms of objects: collections of variables ( fields ) and functions ( methods ).
More informationModule 10 Inheritance, Virtual Functions, and Polymorphism
Module 10 Inheritance, Virtual Functions, and Polymorphism Table of Contents CRITICAL SKILL 10.1: Inheritance Fundamentals... 2 CRITICAL SKILL 10.2: Base Class Access Control... 7 CRITICAL SKILL 10.3:
More informationObject-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)
Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci) Sung Hee Park Department of Mathematics and Computer Science Virginia State University September 18, 2012 The Object-Oriented Paradigm
More informationC++ Important Questions with Answers
1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children
More informationDon t Believe the Hype. CS152: Programming Languages. Lecture 21 Object-Oriented Programming. Class-based OOP. So what is OOP?
Don t Believe the Hype CS152: Programming Languages Lecture 21 Object-Oriented Programming Dan Grossman Spring 2011 OOP lets you: 1. Build some extensible software concisely 2. Exploit an intuitive analogy
More informationJava Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p.
Preface p. xix Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p. 5 Java Applets and Applications p. 5
More informationTable of Contents Preface Bare Necessities... 17
Table of Contents Preface... 13 What this book is about?... 13 Who is this book for?... 14 What to read next?... 14 Personages... 14 Style conventions... 15 More information... 15 Bare Necessities... 17
More informationhttps://asd-pa.perfplusk12.com/admin/admin_curric_maps_display.aspx?m=5507&c=618&mo=18917&t=191&sy=2012&bl...
Page 1 of 13 Units: - All - Teacher: ProgIIIJavaI, CORE Course: ProgIIIJavaI Year: 2012-13 Intro to Java How is data stored by a computer system? What does a compiler do? What are the advantages of using
More informationInheritance and Polymorphism
Division of Mathematics and Computer Science Maryville College Outline Inheritance 1 Inheritance 2 3 Outline Inheritance 1 Inheritance 2 3 The "is-a" Relationship Object classification is typically hierarchical.
More informationS.E. Sem. III [CMPN] Object Oriented Programming Methodology
S.E. Sem. III [CMPN] Object Oriented Programming Methodology Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 80 Q.1(a) Write a program to calculate GCD of two numbers in java. [5] (A) import java.util.*;
More informationI BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++
No. of Printed Pages : 3 I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination 05723. June, 2015 BCS-031 : PROGRAMMING IN C ++ Time : 3 hours Maximum Marks : 100 (Weightage 75%)
More informationCONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17
List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code
More informationVIRTUAL FUNCTIONS Chapter 10
1 VIRTUAL FUNCTIONS Chapter 10 OBJECTIVES Polymorphism in C++ Pointers to derived classes Important point on inheritance Introduction to virtual functions Virtual destructors More about virtual functions
More informationCSE450. Translation of Programming Languages. Lecture 11: Semantic Analysis: Types & Type Checking
CSE450 Translation of Programming Languages Lecture 11: Semantic Analysis: Types & Type Checking Structure Project 1 - of a Project 2 - Compiler Today! Project 3 - Source Language Lexical Analyzer Syntax
More informationRecall. Key terms. Review. Encapsulation (by getters, setters, properties) OOP Features. CSC148 Intro. to Computer Science
CSC148 Intro. to Computer Science Lecture 3: designing classes, special methods, composition, inheritance, Stack, Sack Amir H. Chinaei, Summer 2016 Office Hours: R 10-12 BA4222 ahchinaei@cs.toronto.edu
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationAbsolute C++ Walter Savitch
Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents
More informationContents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix
PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2016 Lecture 7a Andrew Tolmach Portland State University 1994-2016 Values and Types We divide the universe of values according to types A type is a set of values and a
More informationInheritance and Polymorphism
Division of Mathematics and Computer Science Maryville College Outline Inheritance 1 Inheritance 2 3 Outline Inheritance 1 Inheritance 2 3 The "is-a" Relationship The "is-a" Relationship Object classification
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationObject Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming
Overview of OOP Object Oriented Programming is a programming method that combines: a) Data b) Instructions for processing that data into a self-sufficient object that can be used within a program or in
More informationWhere We Are. Lexical Analysis. Syntax Analysis. IR Generation. IR Optimization. Code Generation. Machine Code. Optimization.
Where We Are Source Code Lexical Analysis Syntax Analysis Semantic Analysis IR Generation IR Optimization Code Generation Optimization Machine Code Where We Are Source Code Lexical Analysis Syntax Analysis
More information