Showing posts with label Object Oriented. Show all posts
Showing posts with label Object Oriented. Show all posts

Tuesday, 13 March 2012

Object Oriented Programming Concepts

Object Oriented Programming Basics

As mentioned earlier, object-oriented is a term, which is interpreted differently by different people. It is therefore necessary to understand some of the concepts used extensively in object-oriented programming. We shall now discuss the general concepts of OOP which form the heart I if .lava language.

Objects and Classes

Objects are the basic runtime 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 may handle. They may also represent user-defined data types such as vectors and lists. Any programming problem is analyzed in terms of objects and the nature of communication between them. Program objects should be chosen such that they match closely with the real-world objects. As pointed out earlier, an object takes up space in the memory and has an associated address like a record in Pascal, or a structure in C.

When a program is executed, the objects interact by sending messages to one another. For example, 'customer' and 'account are two objects in a banking program, then the customer object may send a message to the account object requesting for the balance. Each object contains data and code to manipulate the data. Objects can interact without having to know the details of each other's data or code. It is sufficient to know the type of message accepted and the type of response returned by the objects. Although different authors represent them differently, Fig. 1.2 shows ti notation that is Popularly used to represent an object in object oriented analysis and design.

We just mentioned that objects contain data and code to manipulate that data. The entire set of data and code of an object can be made a user-defined data type using the concept of a class. A c!ass may be thought of as a 'data type' and an object as a 'variable' of that data type. Once a class has been defined, we can create any number of objects belonging to that class. Each object is associated Wit lit he data of type class with which they are created. A class is thus a collection of objects of similar type. For example, mango, apple and orange are members of the class fruit.


Classes are user-defined data types and behave like the built-in types of a programming language. For example, the syntax used to create an object is no different than the syntax used to create an integer object in C. If fruit has been defined as a class, then the statement
Fruit mango •
will create an object mango belonging to the class fruit

Sunday, 11 March 2012

OBJECT ORIENTED PARADIGM

Object Oriented:

The major objective of object-oriented approach is to eliminate some of the flaws encountered in the procedural approach. 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 unintentional modification by other functions. 00P allows us to decompose a problem into a number of entities called Objects and then build data and functions (known as methods in Java) around these entities. The combination of data and methods make up an object 



The data of an object can be accessed only by the methods associated with that object,
However, methods of one object can access the methods of other objects. Some of the features of object-oriented paradigm are:

• Emphasis is on data rather than procedure.
• Programs are divided into what are known as Objects.
• Data structures are designed such that they characterize the objects.
• Methods that operate on the data of an object are tied together in the data structure.
• Data is hidden and cannot be accessed by external functions.
• Objects may communicate with each other through methods.
• New data and methods can be easily added whenever necessary.

• Follows botrom-up approach in Program design.

Object-Oriented paradigm is the most recent concept among programming paradigms and
still it means differnt things to diffrent people. It's thefore important to have
a working definition of Object-Oriented programming before we proceed further.

Our definition of Object-Oriented paradigm is:
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. This means that an object is considered to be a partitioned area of computer memory that store data and set of operations that can access that data. Since the memory partition are Independent, the object can be used in a variety of  different programs without modifications.