Encapsulation. Imperative programming abstraction via subprograms Modular programming data abstraction. TUT Pervasive Computing 1
|
|
- Sheila Weaver
- 7 years ago
- Views:
Transcription
1 Encapsulation Imperative programming abstraction via subprograms Modular programming data abstraction Encapsulation grouping of subprograms and the data they manipulate Information hiding abstract data types implementation of the type is hidden from the user variables of the type can be declared variables of the type can be used via the operations defined for the type Mechanisms modules, packages, classes nested subprograms, file system TUT Pervasive Computing 1
2 Module vs. class program modularization (division into parts) separate compilation Module static structure interface and implementation scope Class no code is generated from a module dynamic module it is possible to create run time instances corresponds to a type TUT Pervasive Computing 2
3 Module definition and use (Modula-2) DEFINITION MODULE Stack; PROCEDURE Push ( X: CARDINAL ); PROCEDURE Pop ( ): CARDINAL; VAR Empty, Error: BOOLEAN; END Stack; IMPORT Stack; Stack.Push ( 3 ); FROM Stack IMPORT Push; Push ( 3 ); TUT Pervasive Computing 3
4 Module implementation (Modula-2) IMPLEMENTATION MODULE Stack; CONST N = 100; TYPE Index = [ 0..N ]; VAR Top: Index; S: ARRAY Index OF CARDINAL; PROCEDURE Push ( X: CARDINAL ); PROCEDURE Pop ( ): CARDINAL; BEGIN Error := FALSE; Empty := TRUE; Top := 0; END Stack; BEGIN (* Push *) IF Top = N THEN Error := TRUE; ELSE Top := Top + 1; S [ Top ] := X; Empty := FALSE; END; END Push; BEGIN (* Pop *) IF Top = 0 THEN Error := TRUE; ELSE Top := Top 1; IF Top = 0 THEN Empty := TRUE END; RETURN S [ Top + 1 ]; END; END Pop; TUT Pervasive Computing 4
5 Module use (Modula-2) MODULE StackUser; IMPORT Stack; C: CARDINAL; BEGIN Stack.Push ( 5 ); C := Stack.Pop ( ); END StackUser; Deficiencies of the example: user can change the values of variables Error and Empty it is not possible to create several stacks TUT Pervasive Computing 5
6 Improving the example Using module as a manager for a type (e.g. stack) This requires: an operation to create (initialize) a stack instance an operation to delete a stack instance for each operation an additional parameter to tell which stack instance the operation is applied to Stack type is defined as an opaque type restrictions to variables of this type they can be passed as parameters to module operations they can be assigned and their equality can be tested corresponds to an abstract data type TUT Pervasive Computing 6
7 Definition of an abstract data type Modula-2: DEFINITION MODULE StackManager; TYPE Stack; PROCEDURE Push ( S: Stack, X: CARDINAL ); PROCEDURE Pop ( S: Stack ): CARDINAL; PROCEDURE Empty ( S: Stack ): BOOLEAN; PROCEDURE Initialize ( VAR S: Stack ); END StackManager; Restrictions for an opaque type (in Modula-2): it must be a pointer size is always the same: recompilation is minimized TUT Pervasive Computing 7
8 Modula-2: Implementation of an abstract data type IMPLEMENTATION MODULE StackManager; FROM Storage IMPORT ALLOCATE; CONST N = 100; TYPE Index = [ 1..N ]; StackRec = RECORD Top: Index; StackArr: ARRAY Index OF CARDINAL END; Stack = POINTER TO StackRec; PROCEDURE Pop ( S: Stack ): CARDINAL; BEGIN IF S^.Top > 0 THEN S^.Top := S^.Top 1; RETURN S^.StackArr [ S^.Top + 1 ] END END Pop; PROCEDURE Initialize ( VAR S: Stack ); BEGIN NEW ( S ); S^.Top := 0 END Initialize; END StackManager; TUT Pervasive Computing 8
9 Modula-2: Use of an abstract data type VAR S1, S2: StackManager.Stack; I: CARDINAL; StackManager.Initialize ( S1 ); StackManager.Initialize ( S2 ); StackManager.Push ( S1, 2 ); StackManager.Push ( S2, 3 ); IF NOT StackManager.Empty ( S1 ) THEN I := StackManager.Pop ( S1 ); END; TUT Pervasive Computing 9
10 Shortcomings of modules It is possible to declare several types inside the same module Modules do not totally fulfil the encapsulation intent (i.e. tight cohesion between the type and its operations) An operation in a module is an external object, to which a certain instance (e.g. stack) is passed as a parameter Do not support inheritance (and reuse) TUT Pervasive Computing
11 Classes Put together those objects that have the same behavior Support abstract data types better than modules modules can be used by importing them classes can be used in variable declarations like types Class hierarchy (inheritance) behavior of the superclass instances is copied to be part of the behavior the subclass instances multiple inheritance vs. single inheritance Meta class a class described as a class TUT Pervasive Computing 11
12 package Complex is procedure Initialize ( r, i: Float ); function IsZero return Boolean; private re: Float; im: Float; end Complex; package ComplexManager is with Complex; Complex.Initialize ( 1.0, 2.0 ); if Complex.IsZero then class Complex { public: Complex ( ); Complex ( float, float ); virtual ~Complex ( ); int iszero ( ); private: c1: Complex; float re; }; float im; C++ Ada c2: Complex ( 1.0, 2.0 ); if ( c1.iszero ( ) ) Comparison of modules and classes type Complex is private; procedure Initialize ( c: in out Complex; r: in Float; i: in Float ); function IsZero ( c: Complex ) return Boolean; private type Complex is record re: Float; im: Float; end record; end ComplexManager; with ComplexManager; use ComplexManager; c1, c2 : Complex; Initialize ( c1, 0.0, 0.0 ); Initialize ( c2, 1.0, 2.0 ); if IsZero ( c1 ) then TUT Pervasive Computing 12
13 Design issues for object-oriented languages Exclusivity of objects consistency vs. inefficiency Are subclasses subtypes? consistency between subclasses and superclasses Implementation and interface inheritance dependency vs. inefficiency Single and multiple inheritance Dynamic/static binding, dynamic/static typing Allocation and deallocation of objects Vector v = new Vector ( ); v.addelement ( new Integer ( 10 ) ); C++: Java: int second ( ) { int temp = top ( ); pop ( ); int temp_result = top ( ); push ( temp ); return temp_result; } TUT Pervasive Computing 13
14 Inheritance choices (C++) Implementation inheritance implementation defined as protected in the superclass Interface inheritance implementation defined as private in the superclass Subclass is not a subtype private features of the superclass are not visible in subclasses private inheritance class BaseClass { private: int a; float x; protected: int b; float y; public: int c; float z; }; class SubClass1: public BaseClass { }; class SubClass2: private BaseClass { }; TUT Pervasive Computing 14
15 Influences of inheritance (C++) private-inheritance: natural in this case subclass is not a subtype void push ( int i ) { insert_at_head ( i ); } int pop ( ) { return remove_at_head ( i ); } stack + push ( int ) + pop ( ) linked_list + insert_at_head ( int ) + insert_at_tail ( int ) + remove_at_head ( ) queue + enqueue ( int ) + dequeue ( ) void enqueue ( int i ) { insert_at_tail ( i ); } int dequeue ( ) { return remove_at_head ( i ); } TUT Pervasive Computing 15
16 Object lifetime Creation constructors (zero, one, or several) selecting a constructor (overloading) execution order of the constructors objects as references (e.g. Java, Simula, Smalltalk) explicit creation (constructor call) objects as values (e.g. C++, Oberon, Ada95) creation can be implicit during declaration elaboration Deletion either with explicit command or automatically languages with automated garbage collection do not necessarily need destructors TUT Pervasive Computing 16
17 int a; Objects as values or as references C++: foo a; foo a ( 10 ); foo::foo ( ) foo::foo ( int ) Java: foo a; a = new foo ( ); foo a = new foo ( ); Initialization: foo a; foo c = a; Assignment: foo a, c; c = a; foo::foo ( foo& ) foo::operator= ( foo& ) TUT Pervasive Computing 17
18 Object creation (C++) Automatic object created at declaration elaboration, deleted when exiting the block Static object created when execution starts and deleted when it terminates Dynamic object created and deleted with explicit command class C1 { classc x; } Member object { classc x; } static classc x; or in main: x = new classc; delete x; classc x; created and deleted with the object whose member the member object is TUT Pervasive Computing 18
19 Object creation (in general) Stack memory allocation for objects: size must be known during compilation Inheritance: objects that look like base class objects can really be of derived class! So size depends on situation In many languages memory for objects is always allocated from the heap Same goes for member objects in a class TUT Pervasive Computing
20 Operation binding Dynamic binding = run time binding enables polymorphism that is typical for object orientation implemented via virtual operations Virtual operation operation to be called is selected on the basis of the object s current class Polymorphism in object-oriented languages superclass instance can be replaced with a subclass instance in general a named object can be replaced with another named object genericity, templates (parametric polymorphism) overloading (ad hoc polymorphism) TUT Pervasive Computing 20
21 Static and dynamic binding class person { } class student: public person { } class professor: public person { } contact-operation is defined in all three classes student s; professor p; person *x = &s; person *y = &p; s.contact ( ); // student::contact ( ) p.contact ( ); // professor::contact ( ) x->contact ( ); //?? y->contact ( ); //?? Static binding redefine method is selected on the basis of the variable type Dynamic binding override method is selected on the basis of the object s class TUT Pervasive Computing 21
22 Static and dynamic binding in programming languages Dynamic binding for all operations Smalltalk, Modula-3 Dynamic binding as default Java, added with final definition Eiffel, added with frozen definition Static binding as default C++, added with virtual definition Simula, added with virtual definition Ada95, class wide types used as formal parameters Operations cannot be overridden in subclasses TUT Pervasive Computing 22
23 Implementation of object orientation Features in memory class resembles a record (especially in C++) CIR (class instance record) information static structure about an object each feature can be found by evaluating the offset of the feature subclass adds its own features after the CIR of the superclass Dynamically bound operations references to these operations can be found from CIR list of operations that can be bound dynamically virtual method table (VMT, vtable) information about a class TUT Pervasive Computing 23
24 Implementation of object orientation Dynamically bound operations in dynamically typed object oriented languages each class has a method parser function method parser receives method name and parameters and decides what code to call if parser finds no suitable method, it gives a run-time error if subclass parser finds no suitable method, it calls base class parser(s) before giving an error slower than static methods, but more flexible in some languages, programmer may write custom method parsers for a class TUT Pervasive Computing 24
25 Implementing classes and dynamically bound operations class Foo { int x; double y; char z; public: virtual void k ( ); virtual int l ( ); virtual void m ( ); virtual double n ( ); } f; CIR of f x y z VMT of Foo k l m n code of k code of l code of m code of n TUT Pervasive Computing 25
26 Implementing single inheritance class Bar: public Foo { int w; public: void m ( ); // override virtual double s ( ); virtual char *t ( ); } b; CIR of b x y z w VMT of Bar k code of Foo::k l code of Foo::l m code of Bar::m n code of Foo::n s code of Bar::s t code of Bar::t TUT Pervasive Computing 26
27 Assignment compatibility C++ class foo { } class bar: public foo { } foo f; bar b; foo *fr; bar *br; fr = &b; // ok: the first parts of // data store and VMT // of b are assigned br = &f; // error: f is lacking the // end parts br = dynamic_cast<bar*> ( fr ); Eiffel Backward assignment Reverse assignment class foo class bar inherit foo f: foo; b: bar; f := b; -- ok b?= f; -- assignment -- succeeds, if f refers -- to b object, -- otherwise nil is -- assigned TUT Pervasive Computing 27
28 Choices for multiple inheritance Non-repeated multiple inheritance inherited superclasses are separate in the class hierarchy Repeated multiple inheritance replicated multiple inheritance shared multiple inheritance diamond inheritance B A C B A B D D C A C D TUT Pervasive Computing 28
29 Implementing multiple inheritance Name conflict inherited classes may have features of the same name how to refer to the features of all the superclasses C++: operator :: A Eiffel: renaming B Shared inheritance (diamond inheritance) by which way does D inherit features of A any feature inherited from A can be redefined in B or C D C TUT Pervasive Computing 29
30 B C Non-repeated multiple inheritance D D view, B view C view CIR of D obj. B fields C fields D (only) fields VMT of D (D/B part) B operations D (only) operations VMT of D (C part) C operations TUT Pervasive Computing 30
31 Replicated multiple inheritance A A D view, B view, B::A view C view, C::A view CIR of D obj. B::A fields B (only) fields C::A fields C (only) fields D (only) fields VMT of D (D/B part) B::A operations B (only) operations D (only) operations VMT of D (C part) C::A operations C (only) operations B D A *a; B *b; D *d; a = d; b = d; a = b; C OK. /. TUT Pervasive Computing 31
32 Shared multiple inheritance A D view, B view C view A view CIR of D obj. B (only) fields C (only) fields D (only) fields A fields VMT of D (D/B part) B operations D operations VMT of D (C part) C operations VMT of D (A part) A operations B C D TUT Pervasive Computing 32
Object Oriented Software Design II
Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February
More informationCSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship.
CSCI 253 Object Oriented Design: Java Review OOP George Blankenship George Blankenship 1 Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation Abstract Data Type (ADT) Implementation
More informationGlossary of Object Oriented Terms
Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction
More informationStorage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas
CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage
More informationCOMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms.
COMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms 1 Activation Records activation declaration location Recall that an activation
More informationPolymorphism. Problems with switch statement. Solution - use virtual functions (polymorphism) Polymorphism
Polymorphism Problems with switch statement Programmer may forget to test all possible cases in a switch. Tracking this down can be time consuming and error prone Solution - use virtual functions (polymorphism)
More informationObject-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,
More informationJava Interview Questions and Answers
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 and compile the java
More informationHistory OOP languages Year Language 1967 Simula-67 1983 Smalltalk
History OOP languages Intro 1 Year Language reported dates vary for some languages... design Vs delievered 1957 Fortran High level programming language 1958 Lisp 1959 Cobol 1960 Algol Structured Programming
More informationOrganization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.
Organization of Programming Languages CS320/520N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Names, Bindings, and Scopes A name is a symbolic identifier used
More informationChapter 5 Names, Bindings, Type Checking, and Scopes
Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Scope Scope and Lifetime Referencing Environments Named
More informationCompuScholar, Inc. Alignment to Utah's Computer Programming II Standards
CompuScholar, Inc. Alignment to Utah's Computer Programming II Standards Course Title: TeenCoder: Java Programming Course ISBN: 978 0 9887070 2 3 Course Year: 2015 Note: Citation(s) listed may represent
More informationDescription of Class Mutation Mutation Operators for Java
Description of Class Mutation Mutation Operators for Java Yu-Seung Ma Electronics and Telecommunications Research Institute, Korea ysma@etri.re.kr Jeff Offutt Software Engineering George Mason University
More informationC++ INTERVIEW QUESTIONS
C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get
More informationJava (12 Weeks) Introduction to Java Programming Language
Java (12 Weeks) Topic Lecture No. Introduction to Java Programming Language 1 An Introduction to Java o Java as a Programming Platform, The Java "White Paper" Buzzwords, Java and the Internet, A Short
More informationCS 111 Classes I 1. Software Organization View to this point:
CS 111 Classes I 1 Software Organization View to this point: Data Objects and primitive types Primitive types operators (+, /,,*, %). int, float, double, char, boolean Memory location holds the data Objects
More informationKITES TECHNOLOGY COURSE MODULE (C, C++, DS)
KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL
More informationStack Allocation. Run-Time Data Structures. Static Structures
Run-Time Data Structures Stack Allocation Static Structures For static structures, a fixed address is used throughout execution. This is the oldest and simplest memory organization. In current compilers,
More informationHabanero Extreme Scale Software Research Project
Habanero Extreme Scale Software Research Project Comp215: Java Method Dispatch Zoran Budimlić (Rice University) Always remember that you are absolutely unique. Just like everyone else. - Margaret Mead
More informationImplementation Aspects of OO-Languages
1 Implementation Aspects of OO-Languages Allocation of space for data members: The space for data members is laid out the same way it is done for structures in C or other languages. Specifically: The data
More informationC++FA 5.1 PRACTICE MID-TERM EXAM
C++FA 5.1 PRACTICE MID-TERM EXAM This practicemid-term exam covers sections C++FA 1.1 through C++FA 1.4 of C++ with Financial Applications by Ben Van Vliet, available at www.benvanvliet.net. 1.) A pointer
More informationAn Incomplete C++ Primer. University of Wyoming MA 5310
An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages
More informationThe C Programming Language course syllabus associate level
TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming
More informationSoftware Engineering Techniques
Software Engineering Techniques Low level design issues for programming-in-the-large. Software Quality Design by contract Pre- and post conditions Class invariants Ten do Ten do nots Another type of summary
More informationChapter 13 - Inheritance
Goals Chapter 13 - Inheritance To learn about inheritance To understand how to inherit and override superclass methods To be able to invoke superclass constructors To learn about protected and package
More informationParameter passing in LISP
Parameter passing in LISP The actual parameters in a function call are always expressions, represented as lists structures. LISP provides two main methods of parameter passing: Pass/Call-by-value. The
More information13 Classes & Objects with Constructors/Destructors
13 Classes & Objects with Constructors/Destructors 13.1 Introduction In object oriented programming, the emphasis is on data rather than function. Class is a way that binds the data & function together.
More informationlanguage 1 (source) compiler language 2 (target) Figure 1: Compiling a program
CS 2112 Lecture 27 Interpreters, compilers, and the Java Virtual Machine 1 May 2012 Lecturer: Andrew Myers 1 Interpreters vs. compilers There are two strategies for obtaining runnable code from a program
More informationEl Dorado Union High School District Educational Services
El Dorado Union High School District Course of Study Information Page Course Title: ACE Computer Programming II (#495) Rationale: A continuum of courses, including advanced classes in technology is needed.
More informationInheritance in Programming Languages
Inheritance in Programming Languages Krishnaprasad Thirunarayan Metadata and Languages Laboratory Department of Computer Science and Engineering Wright State University Dayton, OH-45435 INTRODUCTION Inheritance
More informationCIS 190: C/C++ Programming. Polymorphism
CIS 190: C/C++ Programming Polymorphism Outline Review of Inheritance Polymorphism Car Example Virtual Functions Virtual Function Types Virtual Table Pointers Virtual Constructors/Destructors Review of
More informationOn the (un)suitability of Java to be the first programming language
On the (un)suitability of Java to be the first programming language Mirjana Ivanovic Faculty of Science, Department of Mathematics and Informatics Trg Dositeja Obradovica 4, Novi Sad mira @im.ns.ac.yu
More informationAdvanced Data Structures
C++ Advanced Data Structures Chapter 8: Advanced C++ Topics Zhijiang Dong Dept. of Computer Science Middle Tennessee State University Chapter 8: Advanced C++ Topics C++ 1 C++ Syntax of 2 Chapter 8: Advanced
More informationCompiling Object Oriented Languages. What is an Object-Oriented Programming Language? Implementation: Dynamic Binding
Compiling Object Oriented Languages What is an Object-Oriented Programming Language? Last time Dynamic compilation Today Introduction to compiling object oriented languages What are the issues? Objects
More informationObject-Oriented Programming
Object-Oriented Programming Programming with Data Types to enhance reliability and productivity (through reuse and by facilitating evolution) Object (instance) State (fields) Behavior (methods) Identity
More informationEmbedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C
Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C 1 An essential part of any embedded system design Programming 2 Programming in Assembly or HLL Processor and memory-sensitive
More informationC++ Overloading, Constructors, Assignment operator
C++ Overloading, Constructors, Assignment operator 1 Overloading Before looking at the initialization of objects in C++ with constructors, we need to understand what function overloading is In C, two functions
More informationAP Computer Science Java Subset
APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall
More informationJava Application Developer Certificate Program Competencies
Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle
More informationIntroduction to Programming Block Tutorial C/C++
Michael Bader Master s Program Computational Science and Engineering C/C++ Tutorial Overview From Maple to C Variables, Operators, Statements Functions: declaration, definition, parameters Arrays and Pointers
More informationPractical Programming Methodology. Michael Buro. Class Inheritance (CMPUT-201)
Practical Programming Methodology (CMPUT-201) Lecture 16 Michael Buro C++ Class Inheritance Assignments ctor, dtor, cctor, assignment op. and Inheritance Virtual Functions Class Inheritance Object Oriented
More informationChapter 1 Fundamentals of Java Programming
Chapter 1 Fundamentals of Java Programming Computers and Computer Programming Writing and Executing a Java Program Elements of a Java Program Features of Java Accessing the Classes and Class Members The
More informationException Handling. Overloaded methods Interfaces Inheritance hierarchies Constructors. OOP: Exception Handling 1
Exception Handling Error handling in general Java's exception handling mechanism The catch-or-specify priciple Checked and unchecked exceptions Exceptions impact/usage Overloaded methods Interfaces Inheritance
More informationLecture 1: Introduction
Programming Languages Lecture 1: Introduction Benjamin J. Keller Department of Computer Science, Virginia Tech Programming Languages Lecture 1 Introduction 2 Lecture Outline Preview History of Programming
More informationPART-A Questions. 2. How does an enumerated statement differ from a typedef statement?
1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members
More informationCmpSci 187: Programming with Data Structures Spring 2015
CmpSci 187: Programming with Data Structures Spring 2015 Lecture #12 John Ridgway March 10, 2015 1 Implementations of Queues 1.1 Linked Queues A Linked Queue Implementing a queue with a linked list is
More informationInfrastructure that supports (distributed) componentbased application development
Middleware Technologies 1 What is Middleware? Infrastructure that supports (distributed) componentbased application development a.k.a. distributed component platforms mechanisms to enable component communication
More informationSE 360 Advances in Software Development Object Oriented Development in Java. Polymorphism. Dr. Senem Kumova Metin
SE 360 Advances in Software Development Object Oriented Development in Java Polymorphism Dr. Senem Kumova Metin Modified lecture notes of Dr. Hüseyin Akcan Inheritance Object oriented programming languages
More informationCEC225 COURSE COMPACT
CEC225 COURSE COMPACT Course GEC 225 Applied Computer Programming II(2 Units) Compulsory Course Duration Two hours per week for 15 weeks (30 hours) Lecturer Data Name of the lecturer: Dr. Oyelami Olufemi
More informationCS193D Handout 06 Winter 2004 January 26, 2004 Copy Constructor and operator=
CS193D Handout 06 Winter 2004 January 26, 2004 Copy Constructor and operator= We already know that the compiler will supply a default (zero-argument) constructor if the programmer does not specify one.
More informationCS193j, Stanford Handout #10 OOP 3
CS193j, Stanford Handout #10 Summer, 2003 Manu Kumar OOP 3 Abstract Superclass Factor Common Code Up Several related classes with overlapping code Factor common code up into a common superclass Examples
More informationEvolution of the Major Programming Languages
142 Evolution of the Major Programming Languages Object Oriented Programming: Smalltalk Object-Oriented: It s fundamental characteristics are: Data abstraction, Inheritance and Dynamic Binding. The essence
More informationHigh-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)
High-Level Programming Languages Nell Dale & John Lewis (adaptation by Michael Goldwasser) Low-Level Languages What are disadvantages of low-level languages? (e.g., machine code or assembly code) Programming
More informationAPPLE: Advanced Procedural Programming Language Elements
APPLE: Advanced Procedural Programming Language Elements Christian Heinlein Dept. of Computer Structures, University of Ulm, Germany heinlein@informatik.uni ulm.de Abstract. Today s programming languages
More informationFundamentals of Java Programming
Fundamentals of Java Programming This document is exclusive property of Cisco Systems, Inc. Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors
More informationSemantic Analysis: Types and Type Checking
Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors
More informationBoolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)
Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the
More informationFree Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2015 The third
More information1.1.3 Syntax The syntax for creating a derived class is very simple. (You will wish everything else about it were so simple though.
Stewart Weiss Inheritance is a feature that is present in many object-oriented languages such as C++, Eiffel, Java, Ruby, and Smalltalk, but each language implements it in its own way. This chapter explains
More informationClass 16: Function Parameters and Polymorphism
Class 16: Function Parameters and Polymorphism SI 413 - Programming Languages and Implementation Dr. Daniel S. Roche United States Naval Academy Fall 2011 Roche (USNA) SI413 - Class 16 Fall 2011 1 / 15
More informationCommon Data Structures
Data Structures 1 Common Data Structures Arrays (single and multiple dimensional) Linked Lists Stacks Queues Trees Graphs You should already be familiar with arrays, so they will not be discussed. Trees
More informationFree Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2014 Jill Seaman
More informationMOOL: an Object-Oriented Programming Language with Generics and Modules. María Lucía Barrón Estrada
MOOL: an Object-Oriented Programming Language with Generics and Modules. by María Lucía Barrón Estrada Maestro en Ciencias, en Ciencias Computacionales Instituto Tecnológico de Toluca México Licenciado
More informationPHP Object Oriented Classes and objects
Web Development II Department of Software and Computing Systems PHP Object Oriented Classes and objects Sergio Luján Mora Jaume Aragonés Ferrero Department of Software and Computing Systems DLSI - Universidad
More information1 bool operator==(complex a, Complex b) { 2 return a.real()==b.real() 3 && a.imag()==b.imag(); 4 } 1 bool Complex::operator==(Complex b) {
Operators C and C++ 6. Operators Inheritance Virtual Alastair R. Beresford University of Cambridge Lent Term 2008 C++ allows the programmer to overload the built-in operators For example, a new test for
More informationParameter Passing in Pascal
Parameter Passing in Pascal Mordechai Ben-Ari Department of Science Teaching Weizmann Institute of Science Rehovot 76100 Israel ntbenari@wis.weizmann.ac.il Abstract This paper claims that reference parameters
More informationWeb development... the server side (of the force)
Web development... the server side (of the force) Fabien POULARD Document under license Creative Commons Attribution Share Alike 2.5 http://www.creativecommons.org/learnmore Web development... the server
More informationMemory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation
Dynamic Storage Allocation CS 44 Operating Systems Fall 5 Presented By Vibha Prasad Memory Allocation Static Allocation (fixed in size) Sometimes we create data structures that are fixed and don t need
More informationLinked Lists, Stacks, Queues, Deques. It s time for a chainge!
Linked Lists, Stacks, Queues, Deques It s time for a chainge! Learning Goals After this unit, you should be able to... Differentiate an abstraction from an implementation. Define and give examples of problems
More informationClasses and Pointers: Some Peculiarities (cont d.)
Classes and Pointers: Some Peculiarities (cont d.) Assignment operator Built-in assignment operators for classes with pointer member variables may lead to shallow copying of data FIGURE 3-22 Objects objectone
More informationSources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
More informationChapter 13 Storage classes
Chapter 13 Storage classes 1. Storage classes 2. Storage Class auto 3. Storage Class extern 4. Storage Class static 5. Storage Class register 6. Global and Local Variables 7. Nested Blocks with the Same
More information16 Collection Classes
16 Collection Classes Collections are a key feature of the ROOT system. Many, if not most, of the applications you write will use collections. If you have used parameterized C++ collections or polymorphic
More information7.1 Our Current Model
Chapter 7 The Stack In this chapter we examine what is arguably the most important abstract data type in computer science, the stack. We will see that the stack ADT and its implementation are very simple.
More informationData Structures in the Java API
Data Structures in the Java API Vector From the java.util package. Vectors can resize themselves dynamically. Inserting elements into a Vector whose current size is less than its capacity is a relatively
More informationCohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT - BCNS/05/FT - BIS/06/FT - BIS/05/FT - BSE/05/FT - BSE/04/PT-BSE/06/FT
BSc (Hons) in Computer Applications, BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems & BSc (Hons) Software Engineering Cohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT
More informationOpenCL Static C++ Kernel Language Extension
OpenCL Static C++ Kernel Language Extension Document Revision: 04 Advanced Micro Devices Authors: Ofer Rosenberg, Benedict R. Gaster, Bixia Zheng, Irina Lipov December 15, 2011 Contents 1 Overview... 3
More informationJava Interfaces. Recall: A List Interface. Another Java Interface Example. Interface Notes. Why an interface construct? Interfaces & Java Types
Interfaces & Java Types Lecture 10 CS211 Fall 2005 Java Interfaces So far, we have mostly talked about interfaces informally, in the English sense of the word An interface describes how a client interacts
More informationScoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)
Semantic Analysis Scoping (Readings 7.1,7.4,7.6) Static Dynamic Parameter passing methods (7.5) Building symbol tables (7.6) How to use them to find multiply-declared and undeclared variables Type checking
More informationPROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON
PROBLEM SOLVING WITH SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON Addison Wesley Boston San Francisco New York London
More informationProgramming by Contract. Programming by Contract: Motivation. Programming by Contract: Preconditions and Postconditions
COMP209 Object Oriented Programming Designing Classes 2 Mark Hall Programming by Contract (adapted from slides by Mark Utting) Preconditions Postconditions Class invariants Programming by Contract An agreement
More informationMasters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013
Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper
More informationBCS2B02: OOP Concepts and Data Structures Using C++
SECOND SEMESTER BCS2B02: OOP Concepts and Data Structures Using C++ Course Number: 10 Contact Hours per Week: 4 (2T + 2P) Number of Credits: 2 Number of Contact Hours: 30 Hrs. Course Evaluation: Internal
More informationCORBA Programming with TAOX11. The C++11 CORBA Implementation
CORBA Programming with TAOX11 The C++11 CORBA Implementation TAOX11: the CORBA Implementation by Remedy IT TAOX11 simplifies development of CORBA based applications IDL to C++11 language mapping is easy
More informationLecture 7 Notes: Object-Oriented Programming (OOP) and Inheritance
Introduction to C++ January 19, 2011 Massachusetts Institute of Technology 6.096 Lecture 7 Notes: Object-Oriented Programming (OOP) and Inheritance We ve already seen how to define composite datatypes
More informationCrash Course in Java
Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is
More informationProgramming Language Rankings. Lecture 15: Type Inference, polymorphism & Type Classes. Top Combined. Tiobe Index. CSC 131! Fall, 2014!
Programming Language Rankings Lecture 15: Type Inference, polymorphism & Type Classes CSC 131 Fall, 2014 Kim Bruce Top Combined Tiobe Index 1. JavaScript (+1) 2. Java (-1) 3. PHP 4. C# (+2) 5. Python (-1)
More informationa. Inheritance b. Abstraction 1. Explain the following OOPS concepts with an example
1. Explain the following OOPS concepts with an example a. Inheritance It is the ability to create new classes that contain all the methods and properties of a parent class and additional methods and properties.
More informationPart I. Multiple Choice Questions (2 points each):
Part I. Multiple Choice Questions (2 points each): 1. Which of the following is NOT a key component of object oriented programming? (a) Inheritance (b) Encapsulation (c) Polymorphism (d) Parallelism ******
More information1 The Java Virtual Machine
1 The Java Virtual Machine About the Spec Format This document describes the Java virtual machine and the instruction set. In this introduction, each component of the machine is briefly described. This
More informationHandout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
More informationData Structures Using C++ 2E. Chapter 5 Linked Lists
Data Structures Using C++ 2E Chapter 5 Linked Lists Doubly Linked Lists Traversed in either direction Typical operations Initialize the list Destroy the list Determine if list empty Search list for a given
More informationThe Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1
The Java Series Java Essentials I What is Java? Basic Language Constructs Slide 1 What is Java? A general purpose Object Oriented programming language. Created by Sun Microsystems. It s a general purpose
More informationThis lecture. Abstract data types Stacks Queues. ADTs, Stacks, Queues 1. 2004 Goodrich, Tamassia
This lecture Abstract data types Stacks Queues ADTs, Stacks, Queues 1 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations
More informationHow To Write A Program In Java (Programming) On A Microsoft Macbook Or Ipad (For Pc) Or Ipa (For Mac) (For Microsoft) (Programmer) (Or Mac) Or Macbook (For
Projet Java Responsables: Ocan Sankur, Guillaume Scerri (LSV, ENS Cachan) Objectives - Apprendre à programmer en Java - Travailler à plusieurs sur un gros projet qui a plusieurs aspects: graphisme, interface
More informationAndroid Application Development Course Program
Android Application Development Course Program Part I Introduction to Programming 1. Introduction to programming. Compilers, interpreters, virtual machines. Primitive data types, variables, basic operators,
More informationJava from a C perspective. Plan
Java from a C perspective Cristian Bogdan 2D2052/ingint04 Plan Objectives and Book Packages and Classes Types and memory allocation Syntax and C-like Statements Object Orientation (minimal intro) Exceptions,
More information1. Polymorphism in C++...2
1. Polymorphism in C++...2 1.1 Polymorphism and virtual functions... 2 1.2 Function call binding... 3 1.3 Virtual functions... 4 1.4 How C++ implements late binding... 6 1.4.1 Why do I have to know at
More informationProgrammation 2. Introduction à la programmation Java
Programmation 2 Introduction à la programmation Java 1 Course information CM: 6 x 2 hours TP: 6 x 2 hours CM: Alexandru Costan alexandru.costan at inria.fr TP: Vincent Laporte vincent.laporte at irisa.fr
More information