Presentation is loading. Please wait.

Presentation is loading. Please wait.

ProgrammingLanguages Programming Languages Object-oriented Programming Languages This lecture discusses the concept of object- oriented programming.

Similar presentations


Presentation on theme: "ProgrammingLanguages Programming Languages Object-oriented Programming Languages This lecture discusses the concept of object- oriented programming."— Presentation transcript:

1

2 ProgrammingLanguages Programming Languages

3 Object-oriented Programming Languages This lecture discusses the concept of object- oriented programming. The concepts we will cover include the notions of object and classes, patterns for objects, inheritance of operations, the maintenance of control over dependencies, and the dynamic nature of operations as an essential feature of reuse.

4 It began in the 1960s with the Simula project, an attempt to design a programming language that extends Algol60 in a way suitable for performing computer simulations of real-world situations.It began in the 1960s with the Simula project, an attempt to design a programming language that extends Algol60 in a way suitable for performing computer simulations of real-world situations. One of the central ideas was to incorporate the notion of an object,One of the central ideas was to incorporate the notion of an object, Object-oriented programming which, similar to a real-world object, is an entity with certain properties, and with the ability to react in certain ways to events.which, similar to a real-world object, is an entity with certain properties, and with the ability to react in certain ways to events. Simula influences the development of abstract data type mechanisms and the object paradigm.Simula influences the development of abstract data type mechanisms and the object paradigm.

5 Object-oriented programming languages address themselves to two issues in software design:Object-oriented programming languages address themselves to two issues in software design: (1) the need to reuse software components as much as possible,(1) the need to reuse software components as much as possible, Software Reuse and Independence (2) the need to maintain the independence of different components.(2) the need to maintain the independence of different components. extension, restriction, redefinition, abstraction, and "polymorphization“.extension, restriction, redefinition, abstraction, and "polymorphization“. There are five basic ways that a software component can be modified for reuse:There are five basic ways that a software component can be modified for reuse:

6 A text window can be defined as a window with some added text to be displayed. Thus a text window extends a window by adding data, without necessarily changing the operations to be performed.A text window can be defined as a window with some added text to be displayed. Thus a text window extends a window by adding data, without necessarily changing the operations to be performed.Extension As an example of modification by extension, a window is defined on a computer screen as a rectangle specified by its four corners, with operations that may include translate, resize, display, and erase.As an example of modification by extension, a window is defined on a computer screen as a rectangle specified by its four corners, with operations that may include translate, resize, display, and erase. This is the extension of the data and/or operations.This is the extension of the data and/or operations.

7 For example, a rectangle has both a length and a width, but a square has length equal to width, so one piece of data can be dropped in creating a square.For example, a rectangle has both a length and a width, but a square has length equal to width, so one piece of data can be dropped in creating a square.Restriction Restriction is essentially the opposite operation from the extension.Restriction is essentially the opposite operation from the extension. This is the restriction of the data and/or operations.This is the restriction of the data and/or operations. Restriction is a mechanism that is rarely seen in programming languagesRestriction is a mechanism that is rarely seen in programming languages

8 Even if the operations of a new data item remain essentially the same, it may be necessary to redefine some of them to accommodate new behavior.Even if the operations of a new data item remain essentially the same, it may be necessary to redefine some of them to accommodate new behavior.Redefinition This is the redefinition of one or more of the operations.This is the redefinition of one or more of the operations. For example, a square is obtained from a rectangle, an area or perimeter function may need to be redefined to take into account the reduced data needed in the computation.For example, a square is obtained from a rectangle, an area or perimeter function may need to be redefined to take into account the reduced data needed in the computation.

9 Abstraction This is the collection of similar operations from two different components into a new component.This is the collection of similar operations from two different components into a new component. For example, a circle and a rectangle are both objects that have position and that can be translated and displayed.For example, a circle and a rectangle are both objects that have position and that can be translated and displayed. These properties can be combined into an abstract object called a figure,These properties can be combined into an abstract object called a figure, which has the common features of circles, rectangles, triangles, and so on.which has the common features of circles, rectangles, triangles, and so on.

10 Polymorphization or the extension of the type of data that operations can apply to.or the extension of the type of data that operations can apply to. A good example might be that of a print function, which should be applicable to any variable as long as its value is printable.A good example might be that of a print function, which should be applicable to any variable as long as its value is printable. Extending the types that an operation applies to can also be viewed as an example of abstraction, where common operations from different types are abstracted and collected together.Extending the types that an operation applies to can also be viewed as an example of abstraction, where common operations from different types are abstracted and collected together. There are two kinds of polymorphism: overloading and parameterized types.There are two kinds of polymorphism: overloading and parameterized types.

11 Restricting access to internal details Restricting access to internal details of software components is another.Restricting access to internal details of software components is another. Design for reuse is not the only goal of object- oriented languages.Design for reuse is not the only goal of object- oriented languages. Mechanisms for restricting access to internal details go by several names:Mechanisms for restricting access to internal details go by several names: Encapsulation mechanisms,Encapsulation mechanisms, Information hiding mechanisms, orInformation hiding mechanisms, or Protection mechanisms.Protection mechanisms.


Download ppt "ProgrammingLanguages Programming Languages Object-oriented Programming Languages This lecture discusses the concept of object- oriented programming."

Similar presentations


Ads by Google