Basic Concepts Related to OOPS

Posted by in OOPS category on for Beginner level | Points: 250 | Views : 10080 red flag

An overview of the Basic Concepts of OOPS programming
Basic Concepts Related to OOPS

What is OOPS? 

Very Simple ‘Object Oriented Programming System ‘ :).  But most of us are not clear about this during the initial stage of Programming. Let us move on and see till what limit it can be clarified through this article.

Why OOPS? What are the basic principles of OOPS?

Before OOPS concept came in there was a Conventional model of Programming that had a long list of Commands. Not like OOPS, in conventional model, program is seen as a list of tasks (subroutine) to perform!! The Code review will be a horror.

This is where OOPS became important. As the name specify, OOPS program may be viewed as a collection of interacting objects.

Objects are very much related to the real-time objects in the project. These Objects have function related to it. But how can we understand an object, or how can we find the type of the object. Here is where the concept of Class comes.

Class is representation of a type of object. For example, I’m Baimey, I’m an Object of the Class Human Being, or to be more clear ‘Baimey is a Human Being’. I hope the concept of class is clear. But when I’m a human being, I have a number of systems in me, e. g. Respiratory system, which can represent a function.

Functions where available even in the conventional programming system, but here what is the difference. Here function represents the activities of an object. But like a general system, if I say, when we apply brake for an engine it stops. The user can see only the brake lever (abstraction) and Functionality happen in the engine is covered (encapsulation).

Abstraction and Encapsulation came together, along with which we see the concept of Generalization as well. Abstraction places the emphasis on what an object is or does; but here Generalization helps to manage complexity by collecting individuals into groups and providing a representative which can be used to specify any individual of the group; Encapsulation capsules all the complexities or implementation. Any class is an encapsulation of a number of member’s properties and Methods.

When we use OOPS, it provides option for features like inheritance and polymerization.

Inheritance in the common language means getting the characteristics and functionalities of ancestors. Here the scenario is similar, a Base Class, can be inherited by Derived Class. The latter can use and override the functionalities of the former. But multiple inheritances are not allowed in .Net, i.e., a derived class can inherit only from a Base class, but a work around for this is to use Interfaces.

Interfaces are in a sense agreements that must be followed by the inherited class. Interfaces cannot be used (i.e, initialized or made an object) e.g. we make an interface for heartbeating and breathing, when we implement a Person class using this interface it is mandatory that the person class must have the implementation of heartbeating and breathing, else it can’t survive, similarly we can have another interface that says digestive system and urinary system, which can also be implemented in Person class. So here we have 2 interfaces that can be implemented in a Class, at the same time Person class can also inherit from a Base class Human. So here multiple inheritances are made possible.

NB: But keep in mind, the Base class should be referred first, if there is any, when u specify the inheriting classes in a derived class, later you can specify all the interfaces.

When we say about interfaces a short dialog on abstract class is also required. 
Abstract classes are also similar to interfaces, they should be derived, i.e. abstract class also cannot be instantiated. But difference between interface and abstract class is that, interface has only definition of the methods but no implementation, but abstract class can have functions that have implementation and other functions that have only definitions.

Polymorphism is also similar to what the name specifies. A particular function or method can be used with different functionality and same name. This is called overloading and overriding.

In Method overloading methods of the same name defined twice in a class. In this case, these two methods must have a change in number of arguments, type of arguments or order of arguments. But variable change or change in return type can’t be considered. 
In Method overriding the derived class can have its own implementation for the method in the base class. This helps the derived class to have a change in functionality. Suppose if Mammals is the base class then it can be derived by Human or Cow, whose functionalities are different.
Hope this provides a basic overview on the Concepts of OOPS for a beginner. Please keep reading more on each topic. 

Happy Coding :)
Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Baimey Rajesh
Member Level: Starter
Member Status: Member
Member Since: 12/31/2012 4:30:43 AM
Country: Kuwait
Please Mark as Answer If this Helps
I'm a .Net developer with 4 years of experience in India and Kuwait. Currently doing Ms IT. I'm Passionate about technology and helping other to know more about .Net and there by increase and improve my ideas and skill sets.

Login to vote for this post.

Comments or Responses

Posted by: Niranjan44 on: 1/9/2013 | Points: 25
Posted by: Baimey on: 1/10/2013 | Points: 25
Also this books absolutely helps
Please check

Login to post response

Comment using Facebook(Author doesn't get notification)