School of Compupter Science & Engineering Introduction to Object-Oriented-Programming course 67125
|
|
- Frank Turner
- 5 years ago
- Views:
Transcription
1 School of Compupter Science & Engineering Introduction to Object-Oriented-Programming course Slide 1
2 Course Overview Course Goals: (1) Learn advanced Object Oriented Concepts using Java. (2) Learn basic Object-Oriented Design. (3) Implement various data structures using Java. (4) Get to know various important and useful Java classes from the Java API (5) Learn new Java 5.0 features Slide 2
3 Course Topics Object-Oriented Concepts revisited (today's lesson) Progrmming in an Integrated Develpoment Environment (IDE) Input-Output using streams. Advanced Object-Oriented Concepts. Basic Design-Patterns in OOP: Iterator, Composite. A short introduction to UML (Unified Modelling language) Slide 3
4 Course Topics (cont.) Event-Based programming and simulation. Genericity. The Java Collections API. Graphical User Interface and Event-Handling in Java. Implementing data structures in Java. Learning new Java 5.0 concepts and features. Slide 4
5 Course Mechanics Course website: Course Staff: Lecturer:Tomer Hertz Teaching Assistants: Tal El-Hay, Elad Dinur Course Tzar : Moran Yassour Course Duties: 5 programming Exercises Final Exam Many more details in the OOP_Mechanics.pdf file Slide 5
6 Object-Oriented Revisited Object: A thing presented to or capable of being presented to the senses. Object-Oriented: Directed toward just about anything you can think of. Many other different definitions. No clear agreement on what the concept actually means. Slide 6
7 OOP concepts A list of 12 OOP Guru's were locked in a single room. Each one made a list of indespensible OOP propeties. They now had 2 options: (1) Create one long list which is the union of their individual list. (2) Create a short list which is the intersection of their lists. The Guru's chose the 2 nd option and got a very short list indeed: it was the word Encapsulation! Finally someone suggested to choose the most popular properties in all lists! This yielded 9 OOP concepts. Slide 7
8 OOP concepts 9 Object Oriented Concepts: (1) Encapsulation (2) Information/Implementation hiding (3) State retention (4) Object identity (5) Messages (6) Classes (7) Inheritance (8) Polymorphism (9) Genericity Slide 8
9 OOP concepts Karel Revisited In order to understand these concepts let us return to Karel the Robot. The task:we would like to create a program which allows Karel to walk through a path from start to end assuming a single path exists between the two. Slide 9
10 The Karel And KarelWorld Classes Fortunately we already have both a Karel class and a KarelWorld class at our disposal. Karel's API: public boolean setstartlocation(point location) public void turnleft(), public void turnright() public void moveforward() public Point getlocation() public boolean frontisclear() Slide 10
11 The KarelWorld Classes KarelWorld's API: public KarelWorld() public Point getstartposition() public Point getendposition() public void display() Slide 11
12 A solution KarelWorld world = new KarelWorld(); Karel robot = new Karel(); Point startpoint = world.getstartposition(); boolean setok = robot.setstartlocation(startpoint); while(!robot.frontisclear()) robot.turnleft(); while(! robot.getlocation().equals(world.getendposition) ) { while(!robot.frontisclear()) } robot.turnleft(); robot.moverforward(); world.display(); Slide 12
13 Encapsulation Encapsulation is the grouping of related ideas into one unit, which can thenforth be referred to by a single name. An old concept dating back to the early 1940's The basic idea a repeating pattern could be grouped together at a corner of a program and invoked by a single name from several different points in the main program a subroutine/procedure/function - encapsulation of instructions. Advantages: saves computer memory (very important back then!) saves human memory represents a conceptual chunk that can be considered and manipulated as a single idea. Slide 13
14 OOP Encapsulation OOP Encapsulation is the grouping of procedures around data. (more precisely encapsulation of a state within the procedural mechanisms for accessing and modifying that state.) An object consists of a set of methods and a set of variables: frontisclear() getlocation() dir location moveforward() turnleft() Slide 14
15 OOP Encapsulation (cont.) Variables are used internally to remember information. Variables are accessed and updated by an object's methods. Variables are private to the object and cannot be directly accessed. The methods form a protective ring around the central core of the variables. frontisclear() moveforward() getlocation() dir location turnleft() Slide 15
16 Information/Implemention Hiding Information/Implementaion Hiding is the use of encapsulation to restrict from external visibility certain information or implementation decisions that are internal to the encapsulation structure. information hiding information from within the unit cannot be preceived outside the unit. implementation hiding implementation details within the unit cannot be preceived from the outside. Many times the object allows access to information via public methods, but still hides implementation details. Slide 16
17 Information/Implemention Hiding Karel's direction is an example of both information hiding and of implementation hiding: We don't know whether Karel's direction is stored as a char ('e','n','s' or 'w') or as a numerical angle (with values of deg). Note: This is true even if we have implemented a getdirection method. (why?) The object may be seen as a black box to an extent observer. The extent observer has full knowledge of what the object can do, but has no knowledge about how the object does what it does, and how frontisclear() it is constructed internally. moveforward() getlocation() dir turnleft() locatio n Slide 17
18 Information/Implemention Hiding Information/Implementation hiding has 2 major benefits: (1) It localizes decisions private decisions (those within an object) have little or no impact on the rest of the system. Therefore they can be easily made and changed. (limits the ripple of change effect). (2)It decouples the content of information from its form of representation. Thus, an external user of the information content. This prevents external users from meddling with the object's interior. Also prevents introducing connections to an object that depend on tricks or accidents of format and are therefore unstable. Slide 18
19 State Retention An object should have the ability to retain it's state. Traditional procedural modules (e.g. Functions) which die when they return to their caller leaving behind only their result (or return value). Modules have no memory - when the module is called again, its as if it is reborn. An object such as robot, is aware of its past. It retains information inside itself for an indefinite amount of time. Slide 19
20 State Retention Object's State: the values that the object holds. For example: Karel's state includes its current location in the world, and the direction in which it is currently facing. The way in which the object chooses to retain its state is its own internal business. Slide 20
21 Partial Recap So far we have discussed: (1) Encapsulation (2)Information/Implemenation hiding (3)State retention All three are at the core of Object Orientation. However, they are not new ideas and have been studied for years in the field of Abstract Data Types (ADT's). As we'll now see Object Orientation goes well beyond the ADT. Slide 21
22 Object Identity Object identity is the property by which each object (regardless of its class or current state) can be identified and treated as a distinct software entity. Each object has something unique which distinguishes it from all its fellow objects. This something unique is provided by the object-handle mechanism. What is an object handle? Consider the following line of code: Karel robot = new Karel(); The right hand side of this line creates a new object (of class Karel). Slide 22
23 Object Identity (cont.) Karel robot = new Karel(); frontisclear() moveforward() getlocation() dir location turnleft() Object Handle An object handle is an identifier attached to an object when it is created. (AKA Object Identifier (OID)). The object has the same handle for its entire life, regardless of its state during that time. No two objects can have the same handle. Whenever a new object is created at run-time, the system assigns a different handle from all other past, present or future handles. Slide 23
24 Object Identity (cont.) Karel robot = new Karel(); The left-hand side of the line of code is a declaration of a variable by which the programmer can use to refer to a word of memory which can hold a value. The assignment operation can be read as now refers to (or now points to ) causes the variable robot to hold the handle of the object created on the righthand side of the assignment statement. No one (programmer,user,anyone) will ever actually see the handle (102237) of the new object. Instead, the programmer will access the object via the Slide 24
25 Object Identity (cont.) Karel robot = new Karel(); frontisclear() moveforward() robot getlocation() dir location turnleft() In java this handle is a virtual address (and not a physical address). If we create another object it will have a new and different identity. If we now write robot1 = robot; we now have aliasing, but still each of the object's has its own unique ID. Slide 25
26 Messages A Message is the way in which a sender object ob1 conveys to a target object ob2 a demand for object ob2 to apply one of its methods. Message structure a message is comprised of several syntactic parts, each of which is important for OOD. In order for object ob1 to send a message to object ob2, object ob1 must know three things: (1) The handle of ob2 usually kept as one of ob1's variables. (2)The name of the method of ob2 that it wishes to execute. (3)Any additinal information (arguments) that ob2 will require in the execution of its method. Slide 26
27 Messages (Cont.) The karel program provides several examples of messages e.g. robot.turnleft(); Here robot points to (contains the handle of) the target object of the message. turnleft() is the name of the method (of the target object) that's to be executed. Sending of a message therefore looks like traditional calling of a function or procedure. In a procedural language we might have written: turnleft(karel robot); Notice the inversion! Slide 27
28 Messages (Cont.) In the procedural approach, we appeal to a procedural unit and supply it with the object upon which to act. In object orientation, we appeal to the object, which then executes one of its procedural units. While this seems only a syntactic (and maybe also philosophical) difference, when polymorphism, overloading and dynamic binding are introduced, we'll see that this inversion creates and important practical difference between the two approaches. This is because different classes of objects may use the same method name for methods that accomplish different or class-specific behaviours. Slide 28
29 Messages (cont.) Message arguments each message can pass arguments back and forth (input arguments and a return value). These are sometime called the method's signature (types of arguments?) A message therefore consists of 2 parts: the method name and its signature. An object can be a sender and a target in different contexts. Slide 29
30 Three types of messages: Message Types (1) Informative message A message to an object that provides it with information to update itself. (aka update,forward, or push message). A past-oriented message. (2) Interrogative message A message to an object requesting it to reveal some information about itself (aka read,backward or pull message). A present-oriented message. (3) Imperative message A message to an object that requires the object to take some action on itself, another object, or even the envirornment around the system (aka force or action message). A future-oriented message. Slide 30
31 Examples: Message Types Informative message: robot.setstartlocation(point p); tells the Karel object where in the world it has been placed. In general tells the object about something that's happened. Interrogative message: robot.getlocation(); which asks the robot to tell us which square it's currently on. This type of message does not change anything, it usually queries the piece of the world that the object represents. Imperative message: robot.moveforward(); which causes the robot to move forward. This kind of message often results in the target object excuting some significant algorithm in order to work out what to do. (e.g. robot. MoveToWall() ) Slide 31
32 Classes A Class is the stencil from which objects are created (instantiated). Each object has the same structure and behavior as the class from which it is instantiated. Whenever we execute the new command we instantiate an object that is structurally identical to all other objects created from the same class. Structurally identical - all objects from the same class have the same methods and variables, as defined by their class. Objects from the same class differ from one another in 2 ways: (1) Each object has a different object handle. Slide 32 (2)At a particular time, each object will probably have a different
33 Class vs. Object? The distinction between a class and an object: A class is what you design and program Objects are what you create (from a class) at runtime. Therefore Object-Oriented Programming should have been called class-structured programming! Example: Excel (see open office's Calc) is the class from which spreadsheets are created. Each spreadsheet has all the spreadsheet machinery available to is as an instance of the Excel class. One may have many objects from the same class. Slide 33
34 Objects in Memory Suppose we instantiate 3 different objects from the same class. All of them have the same structure (identical variables and methods). In principle each object (instance) of a class has its own copy of the set of methods and variables it needs. However, while (most) variables are indeed object specific, the methods need not be allocated again for each new object from the same class. Therefore all objects share the same physical copy of the methods (to save memory). Slide 34
35 Object methods and variables Recall that an object can have two types of methods variables: Instance methods/variables which belong to individual objects. Class methods/variables (static) which belong to the class. By definition there is always one copy of these regardless of the number of objects which have been instantiated. Example : the constructor method. Slide 35
36 Inheritance Inheritance (by B from A) is the facility by which objects of a class B may use a method or variable that would otherwise be available only to objects of class A, as if the method or variable has been defined upon B. A is termed a superclass of B. B is a subclass of A. Allows to build software incrementally : First build classes to cope with the most straightforward (or general) case. Then, in order to deal with special cases, add more specialized classes and inherit from the first class. The new classes will be entitled to use all the methods and variables (both class and instance) of the original class. Slide 36
37 Inheritance (cont.) Aircraft bool:turn(course:int) Glider ReleaseTowline() isattached:bool Aircraft ac = new Aircraft(); Glider gl = new Glider(); boolean turnok = ac.turn(200); gl.releasetowline(); gl.turn(180); ac.releasetowline(); Slide 37
38 Object vs. Instance We saw the distinction between class and object. There is also a subtle distinction between object and instance inheritance in a sense permits a single object to be simultaneously an instance of more than one class. This corresponds to the real world: if you own a glider (object) it is at the same time an example of a glider and an example of an aircraft. This demonstrates the is a test for inheritance: If you can say a D is a C then D almost certainly should be a subclass of C. Slide 38
39 Polymorphism Comes from two Greek words that mean many and form. Something polymorphic has the ability to take on many forms. Two different definitions in the literature: (A) Polymorphism is the facility by which a single method name may be defined upon more than one class, and may take on different implementations in each of those classes. (B) Polymorphism is the property whereby a variable may point to (hold the handle of) objects of different classes at different times. Slide 39
40 Polymorphism Example: Shapes hierarchy Polygon int:area() Triangle int: area() Rectangle int:area()... Hexagon Slide 40
41 Polymorphism (cont.) The method area() in Polygon would need a fairly sophisticated algorithm in order to compute the area of a general polygon. All of the shapes that inherit from Polygon, inherit the method area(). However, the designer/programmer of area() for rectangle would write the code for this method very differently (and also much simpler and efficient). Slide 41
42 Polymorphism If we have a ref td to type twodshapes which sends a message to its object as follows: td.area(); then (a) We may not know which algorithm for computing area() will be executed. (b) This Reason is that we many not know exactly to which class td belongs. There are 5 possiblities: Triangle, Rectangle, Hexagon, Polygon, Customer Which causes what to happen? Easy to construct simple code in which the class of an object cannot be determined at compile time (how?) Slide 42
43 Polymorphism Where are the 2 definitions of polymorphism here? (1) The method area() being defined on several classes is a good example of polymorphism using definition (A). (2) The variable td, capable of pointing to object of several different classes (for example, Triangle and Hexagon) is an example of polymorphism under definition (B). This shows that these two aspects of polymorphism work together. Slide 43
44 Polymorphism and Dynamic Binding An Object-Oriented environment implements polymorphism is through dynamic binding. The environment inspects the actual class of the target object of a message at the last possible moment at run-time, when the message is sent. Dynamic Binding (or runtime/late binding) is the technique by which the exact piece of code to be executed is assessed only at run-time (as opposed to compile-time). Slide 44
45 Overriding and Overloading Overriding is the definition of a method defined on class C in one of C's subclasses. The method area() originally defined by Polygon is overriden in Triangle. Triangle's method has the same name but a different algorithm. Sometimes overriding can be used to cancel a method by redefining it simply to return an error. Slide 45
46 Overriding and Overloading Overloading a name or a symbol occurs when several methods (or operators) defined on the same class have that name or symbol. We say that the name or symbol is overloaded. Both polymorphism and overloading often require that the specific method to be executed be picked at run-time. (why?) The distinction between polymorphism and overloading is that polymorphism allows the same method name to be defined differently across different classes, while overloading allows the same method name to be defined differently several times in the same class. Slide 46
47 Genericity Genericity is the construction of class C so that one or more of the classes that it uses internally is supplied only at run-time (at the time that an object of class C is instantiated). An informative example Designing a Linked-List: Suppose that you are required to implement a Linked-List of integers for a specific exercise, and then required to implement a Linked-List of shapes for another exercise. What are your design options? Slide 47
48 Genericity (cont.) There are 3 possible solutions: (1) Clone the old code and replace the int data with a Shape reference. (Pros? Cons?) (2) Define the Linked-List data as a reference to Object. (Pros? Cons?) (3) Define the Linked-List to be a generic class, which means that the list's data won't be assigned until run-time Genericity. Slide 48
49 Genericity (cont.) We could define the List class as follows: class List<ListData> { private Node<ListData> head;... public void print(){...} } The <ListData> is a generic class argument whose actual value will be supplied only at run-time. If we instantiate a List object and call the method print we now make fine use of polymorphism, since when it is defined in a generic class, we don't know what the exact type will be. Slide 49 This requires that every type we use will have a print method defined
50 Genericity (cont.) As of Java 1.5 Genericity is an essential part of the language. More on genericity in a few lessons. Slide 50
Inheritance 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 informationComp-304 : Object-Oriented Design What does it mean to be Object Oriented?
Comp-304 : Object-Oriented Design What does it mean to be Object Oriented? What does it mean to be OO? What are the characteristics of Object Oriented programs (later: OO design)? What does Object Oriented
More informationSoftware Paradigms (Lesson 3) Object-Oriented Paradigm (2)
Software Paradigms (Lesson 3) Object-Oriented Paradigm (2) Table of Contents 1 Reusing Classes... 2 1.1 Composition... 2 1.2 Inheritance... 4 1.2.1 Extending Classes... 5 1.2.2 Method Overriding... 7 1.2.3
More informationProgramming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 43 Dynamic Binding (Polymorphism): Part III Welcome to Module
More informationSTUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes
STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes Java Curriculum for AP Computer Science, Student Lesson A20 1 STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes INTRODUCTION:
More informationObject Orientated Analysis and Design. Benjamin Kenwright
Notation Part 2 Object Orientated Analysis and Design Benjamin Kenwright Outline Review What do we mean by Notation and UML? Types of UML View Continue UML Diagram Types Conclusion and Discussion Summary
More informationObjects and Classes. Amirishetty Anjan Kumar. November 27, Computer Science and Engineering Indian Institue of Technology Bombay
Computer Science and Engineering Indian Institue of Technology Bombay November 27, 2004 What is Object Oriented Programming? Identifying objects and assigning responsibilities to these objects. Objects
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 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 informationInheritance (Outsource: )
(Outsource: 9-12 9-14) is a way to form new classes using classes that have already been defined. The new classes, known as derived classes, inherit attributes and behavior of the pre-existing classes,
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 informationCS112 Lecture: Defining Instantiable Classes
CS112 Lecture: Defining Instantiable Classes Last revised 2/3/05 Objectives: 1. To describe the process of defining an instantiable class 2. To discuss public and private visibility modifiers. Materials:
More informationPolymorphism. Object Orientated Programming in Java. Benjamin Kenwright
Polymorphism Object Orientated Programming in Java Benjamin Kenwright Quizzes/Labs Every single person should have done Quiz 00 Introduction Quiz 01 - Java Basics Every single person should have at least
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 informationChapter 6 Introduction to Defining Classes
Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of
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 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 informationInheritance and Polymorphism
Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg
More informationChapter 11 Object and Object- Relational Databases
Chapter 11 Object and Object- Relational Databases Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Outline Overview of Object Database Concepts Object-Relational
More informationCopyright 2016 Ramez Elmasri and Shamkant B. Navathe
Chapter 12 Outline Overview of Object Database Concepts Object-Relational Features Object Database Extensions to SQL ODMG Object Model and the Object Definition Language ODL Object Database Conceptual
More informationCSE 307: Principles of Programming Languages
CSE 307: Principles of Programming Languages Classes and Inheritance R. Sekar 1 / 52 Topics 1. OOP Introduction 2. Type & Subtype 3. Inheritance 4. Overloading and Overriding 2 / 52 Section 1 OOP Introduction
More informationSuper-Classes and sub-classes
Super-Classes and sub-classes Subclasses. Overriding Methods Subclass Constructors Inheritance Hierarchies Polymorphism Casting 1 Subclasses: Often you want to write a class that is a special case of an
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 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 informationCpt S 122 Data Structures. Course Review Midterm Exam # 2
Cpt S 122 Data Structures Course Review Midterm Exam # 2 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 2 When: Monday (11/05) 12:10 pm -1pm
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 information+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.
+ Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create
More information[ L5P1] Object-Oriented Programming: Advanced Concepts
[ L5P1] Object-Oriented Programming: Advanced Concepts Polymorphism Polymorphism is an important and useful concept in the object-oriented paradigm. Take the example of writing a payroll application for
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 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 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 informationReview sheet for Final Exam (List of objectives for this course)
Review sheet for Final Exam (List of objectives for this course) Please be sure to see other review sheets for this semester Please be sure to review tests from this semester Week 1 Introduction Chapter
More informationChapter 5: Procedural abstraction. Function procedures. Function procedures. Proper procedures and function procedures
Chapter 5: Procedural abstraction Proper procedures and function procedures Abstraction in programming enables distinction: What a program unit does How a program unit works This enables separation of
More informationCS250 Intro to CS II. Spring CS250 - Intro to CS II 1
CS250 Intro to CS II Spring 2017 CS250 - Intro to CS II 1 Topics Virtual Functions Pure Virtual Functions Abstract Classes Concrete Classes Binding Time, Static Binding, Dynamic Binding Overriding vs Redefining
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 informationOOP Design Conclusions and Variations
CS108, Stanford Handout #20 Fall, 2008-09 Osvaldo Jiménez OOP Design Conclusions and Variations Thanks to Nick Parlante for much of this handout Part 1 -- Mainstream OOP Design First, we have the standard,
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 informationLecture 36: Cloning. Last time: Today: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting
Lecture 36: Cloning Last time: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting Today: 1. Project #7 assigned 2. equals reconsidered 3. Copying and cloning 4. Composition 11/27/2006
More informationChapter 1: Object-Oriented Programming Using C++
Chapter 1: Object-Oriented Programming Using C++ Objectives Looking ahead in this chapter, we ll consider: Abstract Data Types Encapsulation Inheritance Pointers Polymorphism Data Structures and Algorithms
More informationIntroduction to Object-Oriented Programming
Polymorphism 1 / 19 Introduction to Object-Oriented Programming Today we ll learn how to combine all the elements of object-oriented programming in the design of a program that handles a company payroll.
More informationGraphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java
More informationBCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT OBJECT ORIENTED PROGRAMMING
BCS THE CHARTERED INSTITUTE FOR IT BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT OBJECT ORIENTED PROGRAMMING Wednesady 23 rd March 2016 Afternoon Answer any FOUR questions out of SIX. All
More informationObject-Oriented Design Lecture 23 CS 3500 Fall 2009 (Pucella) Tuesday, Dec 8, 2009
Object-Oriented Design Lecture 23 CS 3500 Fall 2009 (Pucella) Tuesday, Dec 8, 2009 23 Odds and Ends In this lecture, I want to touch on a few topics that we did not have time to cover. 23.1 Factory Methods
More informationObject Oriented Software Development CIS Today: Object Oriented Analysis
Object Oriented Software Development CIS 50-3 Marc Conrad D104 (Park Square Building) Marc.Conrad@luton.ac.uk Today: Object Oriented Analysis The most single important ability in object oriented analysis
More information1. Write two major differences between Object-oriented programming and procedural programming?
1. Write two major differences between Object-oriented programming and procedural programming? A procedural program is written as a list of instructions, telling the computer, step-by-step, what to do:
More informationLesson Plan. Subject: OBJECT ORIENTED PROGRAMMING USING C++ :15 weeks (From January, 2018 to April,2018)
Lesson Plan Name of the Faculty Discipline Semester :Mrs. Reena Rani : Computer Engineering : IV Subject: OBJECT ORIENTED PROGRAMMING USING C++ Lesson Plan Duration :15 weeks (From January, 2018 to April,2018)
More informationLesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014
Lesson 10A OOP Fundamentals By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Definition Pointers vs containers Object vs primitives Constructors Methods Object class
More informationPart 7 - Object Oriented Concepts Classes, Objects, Properties and Methods
Part 7 - Object Oriented Concepts Classes, Objects, Properties and Methods Object Orientated Paradigm... 2 Abstract Data Types (ADT) & Encapsulation... 3 Encapsulation... 5 Classes and Objects... 6 Methods
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 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 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 informationObject Oriented Programming: Based on slides from Skrien Chapter 2
Object Oriented Programming: A Review Based on slides from Skrien Chapter 2 Object-Oriented Programming (OOP) Solution expressed as a set of communicating objects An object encapsulates the behavior and
More informationConcepts of Programming Languages
Concepts of Programming Languages Lecture 10 - Object-Oriented Programming Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages
More informationSoftware Architecture (Lesson 2) Object-Oriented Paradigm (1)
Software Architecture (Lesson 2) Object-Oriented Paradigm (1) Table of Contents Introduction... 2 1.1 Basic Concepts... 2 1.1.1 Objects... 2 1.1.2 Messages... 3 1.1.3 Encapsulation... 4 1.1.4 Classes...
More informationFast Introduction to Object Oriented Programming and C++
Fast Introduction to Object Oriented Programming and C++ Daniel G. Aliaga Note: a compilation of slides from Jacques de Wet, Ohio State University, Chad Willwerth, and Daniel Aliaga. Outline Programming
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 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 informationDay 4. COMP1006/1406 Summer M. Jason Hinek Carleton University
Day 4 COMP1006/1406 Summer 2016 M. Jason Hinek Carleton University today s agenda assignments questions about assignment 2 a quick look back constructors signatures and overloading encapsulation / information
More informationChapter 4 Defining Classes I
Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the
More informationJAVA: A Primer. By: Amrita Rajagopal
JAVA: A Primer By: Amrita Rajagopal 1 Some facts about JAVA JAVA is an Object Oriented Programming language (OOP) Everything in Java is an object application-- a Java program that executes independently
More informationCS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class
CS112 Lecture: Defining Classes Last revised 2/3/06 Objectives: 1. To describe the process of defining an instantiable class Materials: 1. BlueJ SavingsAccount example project 2. Handout of code for SavingsAccount
More informationWeek 8: Operator overloading
Due to various disruptions, we did not get through all the material in the slides below. CS319: Scientific Computing (with C++) Week 8: Operator overloading 1 The copy constructor 2 Operator Overloading
More informationCS 251 Intermediate Programming Methods and Classes
CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationCS 251 Intermediate Programming Methods and More
CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationJava Magistère BFA
Java 101 - Magistère BFA Lesson 3: Object Oriented Programming in Java Stéphane Airiau Université Paris-Dauphine Lesson 3: Object Oriented Programming in Java (Stéphane Airiau) Java 1 Goal : Thou Shalt
More informationPOLYMORPHISM Polymorphism: the type Polymorphism taking many shapes type of object
1 License: http://creativecommons.org/licenses/by-nc-nd/3.0/ POLYMORPHISM There are three major concepts in object-oriented programming: 1. Encapsulation (Classes), Data abstraction, information hiding
More informationThis section provides some reminders and some terminology with which you might not be familiar.
Chapter 3: Functions 3.1 Introduction The previous chapter assumed that all of your Bali code would be written inside a sole main function. But, as you have learned from previous programming courses, modularizing
More informationInheritance. OOP components. Another Example. Is a Vs Has a. Virtual Destructor rule. Virtual Functions 4/13/2017
OOP components For : COP 3330. Object oriented Programming (Using C++) http://www.compgeom.com/~piyush/teach/3330 Data Abstraction Information Hiding, ADTs Encapsulation Type Extensibility Operator Overloading
More informationObject-Oriented Software Engineering. Chapter 2: Review of Object Orientation
Object-Oriented Software Engineering Chapter 2: Review of Object Orientation 2.1 What is Object Orientation? Procedural paradigm: Software is organized around the notion of procedures Procedural abstraction
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract Classes
More informationOBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe
OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++
More informationOops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including:
Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including: Abstraction Encapsulation Inheritance and Polymorphism Object-Oriented
More informationFundamental Concepts and Definitions
Fundamental Concepts and Definitions Identifier / Symbol / Name These terms are synonymous: they refer to the name given to a programming component. Classes, variables, functions, and methods are the most
More informationObject-Oriented Programming Paradigm
Object-Oriented Programming Paradigm Sample Courseware Object-Oriented Programming Paradigm Object-oriented programming approach allows programmers to write computer programs by representing elements of
More informationCS 320 Introduction to Software Engineering Spring March 06, 2017
CS 320 Introduction to Software Engineering Spring 2017 March 06, 2017 Recap: types of Polymorphism Recap: types of Polymorphism Ad-hoc polymorphism (e.g., operator overloading) a + b String vs. int, double,
More informationCMSC 132: Object-Oriented Programming II
CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More information6.001 Notes: Section 17.5
6.001 Notes: Section 17.5 Slide 17.5.1 Now, let's look at one example in which changing the evaluation model allows us to explore a very different kind of computational problem. Our goal is to show how
More informationObject-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1
Object-Oriented Languages and Object-Oriented Design Ghezzi&Jazayeri: OO Languages 1 What is an OO language? In Ada and Modula 2 one can define objects encapsulate a data structure and relevant operations
More informationindex.pdf January 21,
index.pdf January 21, 2013 1 ITI 1121. Introduction to Computing II Circle Let s complete the implementation of the class Circle. Marcel Turcotte School of Electrical Engineering and Computer Science Version
More informationOperator overloading
1 Introduction 2 The copy constructor 3 Operator Overloading 4 Eg 1: Adding two vectors 5 The -> operator 6 The this pointer 7 Overloading = 8 Unary operators 9 Overloading for the matrix class 10 The
More informationPolymorphism: Inheritance Interfaces
Polymorphism: Inheritance Interfaces 256 Recap Finish Deck class methods Questions about assignments? Review Player class for HW9 (starter zip posted) Lessons Learned: Arrays of objects require multiple
More informationCMSC 132: Object-Oriented Programming II
CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation
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 informationDay 3. COMP 1006/1406A Summer M. Jason Hinek Carleton University
Day 3 COMP 1006/1406A Summer 2016 M. Jason Hinek Carleton University today s agenda assignments 1 was due before class 2 is posted (be sure to read early!) a quick look back testing test cases for arrays
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationProgrammazione. Prof. Marco Bertini
Programmazione Prof. Marco Bertini marco.bertini@unifi.it http://www.micc.unifi.it/bertini/ Introduction Why OO Development? Improved structure of software easier to: Understand Maintain Enhance Reusable
More informationChapter 1 Getting Started
Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different
More informationCS 520 Theory and Practice of Software Engineering Fall 2018
Today CS 520 Theory and Practice of Software Engineering Fall 2018 Object Oriented (OO) Design Principles September 13, 2018 Code review and (re)design of an MVC application (and encapsulation) Polymorphism
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance (part II) Polymorphism Version of January 21, 2013 Abstract These lecture notes
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 informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance (part II) Polymorphism Version of January 21, 2013 Abstract These lecture notes
More informationInheritance, Polymorphism, and Interfaces
Inheritance, Polymorphism, and Interfaces Chapter 8 Inheritance Basics (ch.8 idea) Inheritance allows programmer to define a general superclass with certain properties (methods, fields/member variables)
More informationThe major elements of the object-oriented model
The major elements of the object-oriented model Abstraction Encapsulation Inheritance Modularity Suggested Reading: Bruce Eckel, Thinking in Java (Fourth Edition) Reusing Classes Hierarchy 2 An abstraction
More informationMARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012
MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012 Instructor: K. S. Booth Time: 70 minutes (one hour ten minutes)
More informationCLASSES AND OBJECTS IN JAVA
Lesson 8 CLASSES AND OBJECTS IN JAVA (1) Which of the following defines attributes and methods? (a) Class (b) Object (c) Function (d) Variable (2) Which of the following keyword is used to declare Class
More informationSoftware Design and Analysis for Engineers
Software Design and Analysis for Engineers by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc251 Simon Fraser University Slide Set: 2 Date:
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 informationWeek 7. Statically-typed OO languages: C++ Closer look at subtyping
C++ & Subtyping Week 7 Statically-typed OO languages: C++ Closer look at subtyping Why talk about C++? C++ is an OO extension of C Efficiency and flexibility from C OO program organization from Simula
More informationQUIZ. How could we disable the automatic creation of copyconstructors
QUIZ How could we disable the automatic creation of copyconstructors pre-c++11? What syntax feature did C++11 introduce to make the disabling clearer and more permanent? Give a code example. QUIZ How
More information