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

Saturday, 21 April 2012

OOP Application

OOP :

OOP is one of the programming buzzwords today. There appears to be a great deal of excitement and interest among software engineers in using 00P. Applications of 00P are beginning to gain importance in many areas. The most popular application of object-oriented programming, up to now, has been in the area of user interface design such as windows. There are hundreds of windowing systems developed using 00P techniques.
Real-business systems are often much more complex and ,ontain many more objects with complicated attributes and methods. 00P is useful in this type of applications because it can simplify a complex problem. The promising areas for application of 00P includes:
·      Real-time systems
·      Simulation and modelling
·      Object-oriented databases
·      Hypertext, hypermedia and expertext
·      Al and expert systems
·      Neural networks and parallel programming
·      Decision support and office automation systems
·      CIM/CAD/CAD system
It is believed that the richness of OOP environment will enable the software industry to Improve not only the quality of software systems but also its productivity. Object-oriented
Technology is certainly going to change the way software engineers will think, analyze design and implement system in the future .

Sunday, 15 April 2012

Benefits Of OOP

OOP :

OOP offers several benefits to both the program designer and the user. Object-orientation contributes to the solution of many problems associated with the development and quality of software products. The new technology promises greater programmer productivity, better quality of software and lesser maintenance cost. The principal advantages are:
Through inheritance, we can eliminate redundant code and extend the use of existing classes.
We can build programs from the standard working 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.
The principle of data hiding helps the programmer to build secure programs that cannot be invaded by code in other parts of the program.
It is possible to have multiple objects to coexist without any interference.
It is possible to map objects in the problem domain to those objects in the program.
It is easy to partition the work in a project based on objects.
The data-centered design approach enables us to capture more details of a model in an implementable form.
Object-oriented systems can be easily upgraded from small to large systems.
Message passing techniques for communication between objects make the interface descriptions with external systems much simpler.
Software complexity can be easily managed.
While it is possible to incorporate all these features in an object-oriented system, their importance depends on the type of the project and the preference of the programmer. There are a number of issues that need to be tackled to reap some of the benefits stated above. For instance, class libraries must be available for reuse. The technology is still developing and current products may be superseded quickly. Strict controls and protocols need to be developed if reuse is not to be compromised.
A software that is easy to use is hard to build. It is hoped that the object-oriented programming languages like C+ + and Java would help manage this problem.



Wednesday, 11 April 2012

Message Communication

Java - Message Communication :

An object-oriented program consists of a set of objects that communicate with each other. The process of programming in an object-oriented language, therefore, involves the following basic steps:
1. Creating classes that define objects and their behaviour.
2. Creating objects from class definitions.
3. Establishing communication among objects.
Objects communicate with one another by sending and receiving information much the same way as people pass messages to one another as shown in Fig. . The concept of message passing makes it easier to talk about building systems that directly model or simulate their real-world counterparts.



A message for an object is a request for execution of a procedure. and therefore will invoke a method (procedure) in the receiving object that generates the desired result, as shown in Fig.



Message passing involves specifying the name of the object. the name of the method (message) and the information to be sent. For example. consider the statement
Employee.salary(name);


Here. Employee is the object. salary is the message and name is the parameter that contains information.




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



Friday, 6 April 2012

Dynamic Binding

Java - Dynamic Binding :

Binding refers to the linking of a procedure call to the code to be executed in response to the
call. Dynamic binding means that the code associated with a given procedure call is not Know until the time of the call at runtime. It is associated with polymorphism and inheritance. A procedure call associated with a polymorphic reference depends on the dynamic type of the reference.


Consider the procedure "draw" in Fig. By inheritance, every Object will have this procedure. Its algorithm is, however, unique to each object and so the draw procedure will be redefined in each class that defines the object. At run-time, the code matching the object under current reference will he called.


Thursday, 29 March 2012

Polymorphism

Polymorphism :

Polymorphism is another important OOP concept. Polymorphism means the ability to take more than one form. For example, an operation may exhibit different behavior in different instances. The behavior depends upon the types of data used in the operation. For example consider the operation of addition. For two numbers, the operation will generate a sum. If the operands are strings, then the operation would produce a third string by Concatenation. Figure illustrates that a single function name can be used to handle different number and different types of arguments. This is something similar to a particular word having several different meanings depending on the context.


Polymorphism plays an important role in allowing objects having different internal structures to share the same external interface. This means that a general class of operation may be accessed in the same manner even though specific actions associated with each operation may differ. Polymorphism is extensively used in implementing inheritance.

Thursday, 22 March 2012

Inheritance

Inheritance:

Inheritance is the process by which objects of one class acquire the properties of objects of another class. Inheritance supports the concept of hierarchical classification. For example, the bird robin is a part of the class flying bird, which is again a part of the class bird. As illustrated in Fig. 1.4, the principle behind this sort of division is that each derived class shares common characteristics with the class from which it is derived.


Property Inheritance 

 In 00P, the concept of inheritance provides the idea of reusability. This means that we can add additional features to an existing class without modifying it. This is possible by deriving a new class from the existing one. The new class will have the combined features of both the classes. Thus the real appeal and power of the inheritance mechanism is that it allows the Programmer to reuse a class that is almost, but not exactly, what he wants, and to tailor the class in such a way that it does not in introduce any undesirable side effects into the rest of the classes.In Java, the derived class is known as 'subclass'. Note that each subclass defines only those features that are unique to it. without the use of inheritance. each class Would have to explicitly include all of its features.

Thursday, 15 March 2012

Data Abstraction and Encapsulation

Data Abstraction:

The wrapping up of data and methods into a single unit (called class) is known as encapsulation. Data encapsulation is the most striking feature of a class. The data is not accessible to_the outside world and only those methods, which are wrapped in the class, can access it. These methods provide the interface between the object's data and the program. This insulation of the data from direct access by the program is called data hiding. Encapsulation makes it possible tor objects to be treated like 'black boxes', each performing a specific task without any concern for internal implementation

 



Abstraction refers to the act of representing essential features without including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, weight and cost, and methods that operate on these attributes. They encapsulate all the essential properties of the objects that are to be created.

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