Friday, 16 November 2012

OOPS the Basic Funda

Posted by Unknown at 08:20
Object -oriented programming is a programming approach  to promote greater flexibility and maintainability in programming . Various oops concept that makes programming easier in all languages include inheritance and polymorphism .

The oops paradigm involves grouping of data and functions into modular entites knows as objects .You can group more than one objects having similar attributes in program using the class concept . Classes are user -defined data types that contain objects of similar types . Object are instances of a class. You can create any number of objects of  a class.  


What is Object 

An object is merely a collection of related information and functionality. An object can be something that
has a corresponding real-world manifestation (such as an employee object), something that has some
virtual meaning (such as a window on the screen), or just some convenient abstraction within a program
(a list of work to be done, for example).
An object is composed of the data that describes the object and the operations that can be performed
on the object. Information stored in an employee object, for example, might be various identification
information (name, address), work information (job title, salary), and so on. The operations performed
might include creating an employee paycheck or promoting an employee.
When creating an object-oriented design, the first step is to determine what the objects are. When
dealing with real-life objects, this is often straightforward, but when dealing with the virtual world, the
boundaries become less clear. That’s where the art of good design shows up, and it’s why good
architects are in such demand.


Inheritance  

Inheritance is a fundamental feature of an object-oriented system, and it is simply the ability to inherit
data and functionality from a parent object. Rather than developing new objects from scratch, new code
can be based on the work of other programmers[1]
, adding only the new features that are needed. The
parent object that the new work is based upon is known as a base class, and the child object is known
as a derived class.  
Inheritance gets a lot of attention in explanations of object-oriented design, but the use of inheritance
isn’t particularly widespread in most designs. There are several reasons for this.



Polymorphism and Virtual Functions  
A while back I was writing a music system, and I decided that I wanted to be able to support both
WinAmp and Windows Media Player as playback engines, but I didn’t want all of my code to have to
know which engine it was using. I therefore defined an abstract class, which is a class that defines the
functions a derived class must implement, and that sometimes provides functions that are useful to both
classes.
In this case, the abstract class was called MusicServer, and it had functions like Play(),
NextSong(), Pause(), etc. Each of these functions was declared as abstract, so that each player
class would have to implement those functions themselves.
Abstract functions are automatically virtual functions, which allow the programmer to use polymorphism
to make their code simpler. When there is a virtual function, the programmer can pass around a
reference to the abstract class rather than the derived class, and the compiler will write code to call the
appropriate version of the function at runtime.
An example will probably make that clearer. The music system supports both WinAmp and Windows
Media Player as playback engines. The following is a basic outline of what the classes look like:




If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you subscribe to my regular Email Updates. Subscribe Now!


Kindly Bookmark and Share it:

YOUR ADSENSE CODE GOES HERE

0 comments:

Have any question? Feel Free To Post Below:

 

Popular Posts

Recent Comments

© 2011. All Rights Reserved | Object Orienred Programming | Template by Blogger Widgets

Home | About | Top ▲