Presentation is loading. Please wait.

Presentation is loading. Please wait.

O BJECT O RIENTATION F UNDAMENTALS Prepared by: Gunjan Chhabra.

Similar presentations


Presentation on theme: "O BJECT O RIENTATION F UNDAMENTALS Prepared by: Gunjan Chhabra."— Presentation transcript:

1 O BJECT O RIENTATION F UNDAMENTALS Prepared by: Gunjan Chhabra

2 W HAT IS P ROGRAMMING ?

3 T HE T ASK OF P ROGRAMMING Programming a computer involves writing instructions that enable a computer to carry out a single task or a group of tasks A computer programming language requires learning both vocabulary and syntax Programmers use many different programming languages, including BASIC, Pascal, COBOL, RPG, and C++ The rules of any language make up its syntax Machine language is the language that computers can understand; it consists of 1s and 0s

4 T HE T ASK OF P ROGRAMMING A translator (called either a compiler or an interpreter) checks your program for syntax errors A logical error occurs when you use a statement that, although syntactically correct, doesn’t do what you intended

5 P ROCEDURAL P ROGRAMMING Procedural programs consist of a series of steps or procedures that take place one after the other The programmer determines the exact conditions under which a procedure takes place, how often it takes place, and when the program stops Programmers write procedural programs in many programming languages, such as COBOL, BASIC, FORTRAN, and RPG You can also write procedural programs in C++

6 E ARLY P ROCEDURAL P ROGRAMS When programming languages were first used, the programmer’s job was to break a task into small, specific steps Each step was then coded in an appropriate language Three basic control structures are used in procedural programming In the first structure, a sequence, program steps execute one after another, without interruption

7 E ARLY P ROCEDURAL P ROGRAMS Procedural programs also can include a second control structure called selection, which you use to perform different tasks based on a condition The third control structure used in computer programs is the loop some programmers call the loop structure a repetition or iteration structure A procedural programming language usually consists of: A collection of, each of which at any stage contains a certain value (a number, a character, a string of characters, etc.) A collection of that change the values of these variables. The building-block of this type program is the procedure or function.

8 P ROCEDURAL P ROGRAMMING - D ISADVANTAGES Procedures and data are clearly separated. Design models are a long step from implementation. Procedures are often hard to reuse. programs are often hard to extend and maintain.

9 O BJECT -O RIENTED P ROGRAMMING Object-oriented programming requires a different way of thinking and adds several new concepts to programming; You analyze the objects with which you are working—both the attributes of those objects and the tasks that need to be performed with and on those objects You pass messages to objects, requesting the objects to take action The same message works differently when applied to the various objects A method can work appropriately with different types of data it receives, without the need for separate method names Objects can share or inherit traits of previously created objects, thereby reducing the time it takes to create new objects Information hiding is more complete than in procedural programs

10 O BJECT -O RIENTED P ROGRAMMING The basic principles behind using object- oriented programming techniques involve: Objects & Classes Abstraction Encapsulation Abstraction Inheritance Polymorphism

11 O BJECTS AND C LASSES An object is any thing An object has state, behavior, and identity. A class consists of a category of things An object is a specific item that belongs to a class; it is called an instance of a class A class defines the characteristics of its objects and the methods that can be applied to its objects A class is a set of objects that share a common structure and a common behavior.

12 A BSTRACTION  Abstraction can be defined as:  Any model that includes the most important, essential, or distinguishing aspects of something while suppressing or ignoring less important, immaterial, or diversionary details. The result of removing distinctions so as to emphasize commonalties.  Abstraction-  Emphasizes relevant characteristics.  Suppresses other characteristics.

13 E NCAPSULATION Encapsulation means to design, produce, and describe software so that it can be easily used without knowing the details of how it works. Also known as information hiding

14 I NHERITANCE Inheritance —a way of organizing classes Term comes from inheritance of traits like eye color, hair color, and so on. Classes with properties in common can be grouped so that their common properties are only defined once. Vehicle AutomobileMotorcycleBus SedanSports CarSchool BusLuxury Bus

15 P OLYMORPHISM Polymorphism —the same word or phrase can be mean different things in different contexts Analogy: in English, bank can mean side of a river or a place to put money

16 A PPLICATIONS AND B ENEFITS OF USING OOP S Main application areas of OOP are User interface design such as windows, menu,… Real Time Systems Simulation and Modeling Object oriented databases AI and Expert System Neural Networks and parallel programming Decision support and office automation system and so on….

17 A PPLICATIONS AND B ENEFITS OF USING OOP S Benefits of OOP It is easy to model a real system as real objects are represented by programming objects in OOP. The objects are processed by their member data and functions. It is easy to analyze the user requirements. With the help of inheritance, we can reuse the existing class to derive a new class such that the redundant code is eliminated and the use of existing class is extended. This saves time and cost of program. In OOP, data can be made private to a class such that only member functions of the class can access the data. This principle of data hiding helps the programmer to build a secure program that can not be invaded by code in other part of the program. With the help of polymorphism, the same function or same operator can be used for different purposes. This helps to manage software complexity easily. Large problems can be reduced to smaller and more manageable problems. It is easy to partition the work in a project based on objects. It is possible to have multiple instances of an object to co-exist without any interference i.e. each object has its own separate member data and function.

18 S UMMARY Programming a computer involves learning the syntax of a computer programming language and resolving logical errors All programming languages provide methods for input and output of variable values You declare a variable by providing it with a name and a type Procedural programs consist of a series of steps or procedures that take place one after the other Object-oriented programming adds several new programming concepts including objects, classes, inheritance, and polymorphism


Download ppt "O BJECT O RIENTATION F UNDAMENTALS Prepared by: Gunjan Chhabra."

Similar presentations


Ads by Google