Unformatted text preview:

A. Bellaachia Page: 1 Object-Oriented Paradigm 1. Objectives ................................................................. 2 2. A little Bit of History................................................. 3 3. Overview .................................................................. 4 4. Objects ...................................................................... 5 5. Messages ................................................................... 6 6. Classes ...................................................................... 7 7. Classes and Objects ................................................... 8 8. Object-oriented characteristics................................... 9 9. Implementation of Object-Oriented Constructs ........ 15 10. Dynamic Binding .................................................... 18 11. OO Programming Languages .................................. 20 11.1. C++ ................................................................. 20 11.2. Java ................................................................. 24 11.3. Features Removed from C and C++ .......... Error! Bookmark not defined. 11.4. Python ............................................................. 30A. Bellaachia Page: 2 1. Objectives - Object technology helps build complex applications quickly: applications are created from existing components - Easier design: designer looks at objects as a black box, not concerned with the detail inside - Software Reuse: Classes are designed so they can be reused in many systems or create modified classes using inheritance - Enhance the software product quality: Reliability, Productivity, etc - Support for software adaptability more easily - Support the move towards distributed systems - Robustness - classes designed for repeated reuse become stable over timeA. Bellaachia Page: 3 2. A little Bit of History - Object-oriented paradigm has its roots back to Simula (Simulation of real systems) language that was developed by in 1960 by researchers at the Norwegian Computing Center. - In 1970, Alan Kay and his research group at Xerox PARK (the Palo Alto Research Center) developed the first pure OOPL: Smalltalk. - In parallel to Alan’s work, Bjarne Stroustrup at Bell Laboratories was also developing an extension to C language, called C++, that implements the OO concepts. - By the time of the first major conference on OO programming, in 1986, there were dozens of languages: Object C (1986), Eiffel (1988), Object Pascal, etc.A. Bellaachia Page: 4 3. Overview - The object-oriented paradigm shifts the focus of attention from code to data. - OO is based on modeling real-world objects - The general approach of OOP is to view a software system as a collection of interacting entities called "objects" each of which is defined by an identity, a state described in terms of member variables, and a behavior described in terms of methods that can be invoked. - The basic unit of abstraction is the OBJECT, which encapsulates both state information (in the form of the values of instance variables) and behavior (in the form of methods, which are basically procedures.) - Most object-oriented programming languages are fairly similar to imperative languages - the paradigm shift is more in how we THINK about problem solving than it is in the style of the programming language we use. - Examples: Simula, Smalltalk, Eiffel, Objective-C, C++, JavaA. Bellaachia Page: 5 4. Objects - Philosophical definition: An entity that you can recognize - In object technology terms: An abstraction of a “real-world” object. - In software terms: A data structure and associated functions. - Object technology decomposes a system entirely into objects. - The object can perform operations: You can ask the object: “what can you do for me? o An ATM machine object will have the following operations: Withdraw, print receipt, swipe card, and so on. o An object pen can have the following operations: Write, leak ink, etc. - Each object has knowledge (attribute) about its current state: o The ATM object has the following attributes: cash on hand, cards recognized, ATM code, etc. o The pen object has the attributes: amount of ink remaining, etc. - Question: How do you decide what operations and attributes are relevant to your object? Are you interested in the age or length of the pen? - Aggregation: Objects may be made of other objectsA. Bellaachia Page: 6 5. Messages - Objects can communicate between each other by sending messages. - The interactions among objects are described in terms of ‘messages’, which are effectively procedure calls executed in the context of the receiving object. - A message represents a command sent to an object (recipient or receiver) to perform a certain action by invoking one of the methods of the recipient. - A message consists of the following:  Receiving object,  The method to be invoked, and  Optionally the arguments of the method. - Example: Panel1.add(button1); Recipient: panel1 Method add Arguments: button1A. Bellaachia Page: 7 6. Classes - The world has too many objects and we classify these objects into categories or classes - A class is a template for a group of objects. - It is a specification of all the operations and attributes for a type of object. - Classes can also be viewed as cookie-cutter: each class creates cookies (objects) of the same shape (set of operations, attributes). - Example: o Define a pen class as follows: - Operations: write: check the amount of the ink and refuse to write if the pen is empty, refill: Add ink to the pen if it is empty. - Attributes: ink color, ink remaining, o Create pen objects: my pen, you pen, etc. - A number of different relationships can hold among them: Fundamental ones are inheritance and aggregation that relate classes to each other, and ‘instanceOf’ which relates a class to its instances.A. Bellaachia Page: 8 7. Classes and Objects - Classes are static definitions that enable us to understand all the objects of that class. They are only concepts to help us understand the real world. They do not exist at run time. - Objects are dynamic entities that exist in the real world and are available at run time. - An object is an instance of a class. - OO users use the two words class and object interchangeably.A. Bellaachia Page: 9 8. Object-oriented characteristics -


View Full Document

GWU CSCI 210 - Object-Oriented Paradigm

Download Object-Oriented Paradigm
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Object-Oriented Paradigm and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Object-Oriented Paradigm 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?