Sie sind auf Seite 1von 5

PRINCIPLES OF OBJECT ORIENTED PROGRAMMING

Software Evolution: Earnest Tello a well-known writer compared the evolution of software technology to the growth of
a tree.

1, 0 Machine Language Assembly Language Procedure Programming Object-oriented Programming Procedure Oriented Programming: High level languages such as COBOL, FORTRAN and C are commonly known as procedure-oriented programming. In the procedure-oriented approach, the problem is viewed as a sequence of things to be done, such as reading, calculating and printing. Procedure-oriented programming basically consists of writing a list of instructions into groups known as functions. Characteristics: 1. 2. 3. 4. 5. Emphasis is on doing things (algorithms) Large programs are divided into smaller programs known as functions Most of the functions share global data Functions transforms data from one form to another Employs top-down approach in program design.

Object-Oriented Programming: OOP treats data as a critical element in the program development and does not allow it to flow freely around the system. It ties data more closely to the functions that operate on it and protects it from accidental modification from outside functions. OOP allows us to decompose a problem into a number of entities called objects and then builds data and functions around these entities. Features: 1. Emphasis is on data rather than procedure 2. Programs are divided into what are known as objects 3. Data is hidden and cannot be accessed by external functions 4. Objects may communicate with each other though functions 5. New data and functions can be easily added whenever necessary 6. Follows bottom-up approach in program design. Definition: Object-oriented programming is an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on demand. Basic Concepts of Object-Oriented Programming 1. OBJECTS 3. DATA ABSTRACTION 5. INHERITENCE 7. DYNAMIC BINDING 2. CLASSES 4. DATA ENCAPSULATION 6. POLYMORPHISM 8. MESSAGE PASSING

1. Objects: Objects are the basic run-time entities in an object-oriented system. They may represent a person, a place, a bank account, a table of data or any item that the program must handle. Programming problem is analyzed in terms of objects. When a program is executed, the objects interact by sending messages to one another. For example if customer and account are two objects in a program, then the customer object may

send message to the account object requesting for the bank balance. Each object contains data and code to manipulate the data. --------------------------------------------------Object : STUDENT --------------------------------------------------DATA Name Date-of-birth Marks -----------------------------------------------------------FUNCTIONS Total Average Display --------------------------------------------------Objects serve two purposes: They promote understanding of the real world and provide a practical basis for computer implementation. All Objects have identity and are distinguishable. 2. Classes: An Object class describes a group of objects with similar properties (attributes), common behavior (operations) and common relationships to other objects. Objects in a class have the same attributes and behavior patterns. The entire set of data and code of an object can be made a user defined data type with the help of a class. For ex: Mango, Apple, Orange are the members of the class fruit. If fruit has been defined as a class then the statement fruit mango; will create an object mango belonging to the class fruit. A class serves as a blue print or a plan or a template. It specifies what data and what functions will be included in objects of that class. Person (Person) (Person) stanly joe Fig: Class and Objects (Person) joe 24 (Person) mary

Person Name:string age:integer

(Person) Smith 52

Class with Attributes Objects with Values An attribute is a data value held by the objects in a class. 3. Data Abstraction: It consists of focussing on the essential inherent aspects of an entity. Most modern languages provide data abstraction, but the ability to use inheritance and polymorphism provides additional power. Classes use the concept of abstraction, they are known as Abstract Data Types. 4. Encapsulation: It is also termed as information hiding. The wrapping up of data and functions into a single unit is known as encapsulation. It is the most essential feature of a class. The data is not accessible to the outside and only those functions in the class can access it.

5. Inheritance: Inheritance is the sharing of attributes and operations among classes based on a hierarchical relationship. (or) Inheritance is the process by which objects of one class acquire the properties of objects of another class. Using a concept of inheritance new classes can be built from the old ones. The new class referred to as a derived class, can inherit the data structures and functions of the original or the base class. The new class can add data elements and functions to those it inherits from its base class. For ex: 1. Scrolling window and Fixed window are subclasses of window. 2. BIRD Attributes: -------------------

FLYING BIRD NON FLYING BIRD Attributes Attributes ------------------------------------ROBIN SWALLOW PENGUIN KIWI Attributes Attributes Attributes Attributes ------------------------------------------------------------------------The bird ROBIN is a part of the class FLYING BIRD that is again a part of the class BIRD. In Object Oriented Programming, the concept of inheritance provides the idea of reusability. This means that we can add additional features to an existing class without modifying it. 6. Polymorphism: Polymorphism is another important Object-Oriented Programming concept. Polymorphism means that the same operation may behave differently on different classes. For example:The move operation may behave differently on the windows and chess piece classes. Polymorphism plays an important role in allowing objects involving different internal structures to share the same external interface. Polymorphism is extensively used in implementing inheritance. SHAPE Draw() CIRCLE object ---------Draw(circle) BOX object ---------Draw(box) TRIANGLE object ---------Draw(triangle)

2. Dynamic Binding: Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run time. It is associated with polymorphism and inheritance.
3.

Message Communication:An Object-Oriented Programming consists of a set of objects that communicate with each other.
Objects communicate with one another by sending and receiving information. Message passing involves specifying the name of object, the name of function (message) and information to be sent.

Ex:

Employee Object

Salary Message

(Name) Information

Objects have a life cycle. They can be created and destroyed. Communication with an object is feasible as long as it is alive.

Benefits of OOP: 1. Through inheritance, we can eliminate redundant code and extend the use of existing classes. 2. We can build programs from the standard working the modules that communicate with one another, rather than having to start writing the code from scratch. This leads to saving of development time and higher productivity. 3. The principle of data hiding helps the programmer to build secure programs that cannot be invaded by the code in other parts of the program. 4. It is possible to have multiple instances of an object to coexist without any interference. 5. It is possible to map objects in the problem domain to those in the program. 6. It is easy to partition the work in a project based on objects. 7. The data centered design approach enables us to capture more details of a model in implement able form. 8. Object oriented systems can be easily upgraded from small to large system. 9. Message passing techniques for communication between objects makes the interface. Applications of OOP: 1. Real time systems 2. Simulations and modeling 3. Object oriented database 4. Hypertext, hypermedia and expertext 5. AI and expert systems 6. Neural networks and parallel programming 7. Decision support and office automation systems 8. CIM / CAM /CAD systems

INTRODUCTION TO Java
The Evolution Of C++ / What Is C++: C++ is an Object-Oriented Programming language. Initially named 'C with classes'. In the early 1980's "Bjarne Stroustrup" working at Bell Labs developed the C++ language. Its main purpose is to make writing good programs easier for the programmer. C++ Object-Oriented Programming aspect was inspired by a computer simulation language called simula 67. Stroustrup added Object-Oriented Programming features to 'C' and create a more powerful language called C++. Therefore C++ is an extension of C with a major addition of class construct feature of simula 67. C++ is a superset of C, meaning that any valid C programming is a C++ program too. C++ is called a hybrid language because it can be used both as a procedure language like C and as an Object-Oriented Programming language like simula 67. Other Object-Oriented Programming languages include 'Smalltalk' and 'Ada'. Applications of C++ C++ is versatile language for handling very large programs. It is suitable for development of editors, compilers, databases, communication systems and real life application systems. C++ programs are easily maintainable and expandable. Program Features A C++ program is a collection of functions. Every executable C++ program must contain the main ( ) function. A C++ statement is a complete instruction given to the computer and must be terminated with a semicolon. C++ is a free from language. Structure of C++ Program:

Include files Class declarations Class functions Definitions Main function program Creation and Execution of Programs: 1. 2. 3. 4. 5. 6. Develop the program (source code) Select a suitable file name Compile the source code. The file containing the translated code is called object code file. If there are any errors, debug them and compile the program again. Link the object code with other library code that are required for execution. Run the executable code and obtain the results.

Das könnte Ihnen auch gefallen