Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP.

Similar presentations

Presentation on theme: "1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP."— Presentation transcript:


2 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP has data (the attributes) and code that responds to instructions. Think of the code and data as being welded together --the code completely wrapping the data in a shell to protect it from the hostile outside world." [Franz]

3 3 What is an object? (Continued)  ”An object has state, behavior, and identity; [Booch 91]  “ An object is an encapsulation of state (data values) and behavior (operations). Thus an object is in many ways similar to a module, or an abstract data type." [Budd]

4 4 Procedural languages vs Object- oriented languages?  Procedural languages (Pascal, C, Fortran, etc.) operate on data a step at a time. A program written in one of these languages has two components: data (variables and records) code (instructions that act on the data and do the work). There is a rigid separation of code from data.

5 5 PRO-Lang vs OO-Lang (Continued)  An object-oriented language breaks a program into hundreds of tiny entities that have small bits of code and data fused tightly together. Where subroutines are a convenience in a procedural language, the separateness of these entities is essential to an object-oriented program.

6 6 OBJECT-ORIENTATION - A NEW PARADIGM  Object-oriented programming is a new programming paradigm (a new way of viewing the world).  The underlying ideas of the object-oriented technique are the same basic methods humans use to solve problems in the world (e.g., abstraction).

7 7 OO A NEW PARADIGM (Continued)  Computer novices and children grasp the ideas of OOP easier than computer professionals. The professionals require a paradigm shift which is very difficult (due to preconceived notions) whereas the children don't.

8 8 TERMS:  Object: A software entity that mirrors the real world in some way. Everything in an object-oriented programming language is an object.  Class: A class is a template from which objects are created (i.e., a blueprint for the objects it defines). Every object made from a class is the same as every other.

9 9 TERMS: (Continued)  Instance: Instances are the individual objects created by a class. Every object is an instance of a class. Related Term:  Instantiation: Creating a new (specific) object from a general class is called instantiation.

10 10 TERMS: (Continued)  Method: The behavior of a class, and all its instances, is described by a method. Methods are like procedures:  They execute step-by-step,  Can do branching and looping,  Take arguments,  Have local variables,  Return values (objects).

11 11 TERMS: (Continued)  Methods are unlike procedures:  they may only access data of the class for which they are defined, an instance's data can only be accessed through its class' method. Note: A class' methods completely encapsulate the data of objects of the class for which they are defined.

12 12 TERMS: (Continued)  Message: A request to a specific instance, called the receiver, to invoke a specific method. Along with the name of the method, (the selector) additional information (arguments, i.e., objects) can be passed as part of the message.

13 13 TERMS: (Continued)  When the object receives the message, it invokes the method for the selector. This can: (1) change the object's instance variables, (2) send another object back as a direct response to the message, (3) do something in the real world of the computer, such as display information, print a message, or read a block of data from a file. Much of the code within methods consists of passing messages to other objects.

14 14 TERMS: (Continued)  Abstraction: A problem solving tool that allows one to think of a problem at a higher level without worrying about the details.  Abstraction refers to organizing information based on three abstraction mechanisms: classification, generalization, and aggregation.

15 15 ABSTRACTION MECHANISMS (Continued)  Classification forms new objects by suppressing the details of individual instances and emphasizing properties of the whole. New object types (classes) are formed by collecting instances. Classification = set theoretic operation 'membership' ==> describes the 'instance-of' relationship

16 16 ABSTRACTION MECHANISMS (Continued) EX: Classification would allow one to collect the instances '{Jane, Bob, Sue}' into a new higher-order type called 'secretary.'

17 17 ABSTRACTION MECHANISMS (Continued)  Generalization merges existing types to form new types. Individual differences between subtypes are ignored and common traits are emphasized. Generalization = set theoretic operation 'union' ==> describes the 'is-a‘ relationship

18 18 ABSTRACTION MECHANISMS (Continued) EX: Existing employee types 'secretary', and 'teacher' can be generalized to form the new type 'employee'.

19 19 ABSTRACTION MECHANISMS (Continued) Generalization implies that every instance of the subtype is an instance of the type. Every instance of 'teacher' is also an instance of 'employee'

20 20 ABSTRACTION MECHANISMS (Continued)  Aggregation forms an object as a relationship among other objects. It suppresses the details of the components and emphasizes the details of the relationship as a whole. Aggregation = set theoretic operation 'cartesian product' ==> describes the 'is-part-of‘ relationship

21 21 ABSTRACTION MECHANISMS (Continued) EX: Consider object types 'stove', 'refrigerator', 'sink', 'cabinet'. A 'kitchen' object can be abstracted from the given objects. The individual objects (e.g., 'stove') are components of the aggregate ('kitchen').

22 22 ABSTRACTION MECHANISMS (Continued) An instance of a component is said to be an attribute of an instance of the aggregate.

23 23 ABSTRACTION MECHANISMS (Continued)  Classification, generalization, and aggregation are the basic ways we have of structuring information. When they are repeatedly applied to objects, hierarchies of new objects are formed.

24 24 TERMS: (Continued)  Information hiding as defined by Parnas [Par72] suggests decomposing systems into components that hide or encapsulate design decisions about abstractions.  Data abstraction refers to defining data types in terms of the operations that apply to objects of the type, with the constraint that the values of such objects can be modified and observed only by the use of the operations [Oxf86].

25 25 TERMS: (Continued)  Data abstraction is thinking in terms of what you can do to a collection of data independently of how you do it. Related term:  Abstract data type (ADT) is a collection of data structured in a particular fashion together with a set of operations that manipulate the data.

26 26 TERMS: (Continued)  Inheritance: The principle of receiving properties or characteristics from an ancestor and is used to define new data types as extensions or restrictions of existing types.  Polymorphism and dynamic binding: Program entities should be permitted to refer to objects of more than one class, and operations should be permitted to have different realizations in different classes.

27 27 TERMS: (Continued) o Polymorphism: refers to the situation whereby a given program entity may refer at run-time to instances of different classes. o Dynamic binding: refers to the situation whereby the run-time system will automatically select the version of an operation adapted to the corresponding instance.

28 28 TERMS: (Continued)  Multiple and repeated inheritance: It should be possible to declare a class as heir to more than one class, and more than once to the same class.

Download ppt "1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP."

Similar presentations

Ads by Google