Object Oriented Concepts - Part I


What is OOPs?

OOPs is stands for Object Oriented Programming. It is a design philosophy. Programming language consist of data fields and methods. We use methods and data fields for developing applications. OOPs define some guidelines to design applications and programs.

What is Object?


In real life everything is an object. For instance, chair is an object, table is an object. The object may be living object or non living. Each and every object has peculiar behavior and attributes. If you take human as example his character is attribute and his activities are behaviors. As like real time our programming language objects also having some attributes and behavior. In program object elements are attributes and methods are behavior.

What is Class?

Blue print of object is called as class.

Object and Class Relationship:


For instance “marriage” is an application. Before marriage we print invitation. The invitation is a class.

How the invitation is a class?

What the invitation consist? The invitation consist the matter of what is the function? Where is the function? When is the function? The details of groom and bride groom etc. Same as marriage the class consists the code of data members and functions. So we can tell the invitation and classes are blue print.

How to relate object in marriage?


How the marriage will happen. The marriage will be over by changing rings between boy and girl. So actual binding taken place by changing ring. Here the ring is like object. The class will be called when the object instantiated.

Coding Example:

class Program
{
    void
method()
    {
        Console
.WriteLine("Class");
    }
    static
void Main(string[] args)
    {
        Program
obj = new Program();
        obj.method();
        Console
.ReadLine();
    }
}

Why OOPs?

In application some data's will be used throughout the application. That time the data have to be travel and should be protected. To protect the data member information we can go for oops concepts.

In some other cases we use functions in different pages. That time we need to write same function in multiple pages .Because of rewriting the time and space will be wasted. You can solve this problem by using oops. By oops you can use existing function for every time instead of writing new function.

The OOPs allows us to use same function for different purpose.

How OOPs?
  1. Protected data transfer can be achieved by encapsulation
  2. Reuse of function is achieved by inheritance
  3. Multiple form of single function is achieved by Polymorphism
Advantages of OOPs:

Object-Oriented Programming has the following advantages
  • Existing code can be changed easily at run time
  • The OOPs use interface between classes to avoid dependency
  • Create clear modular structure
Basic OOPs Concepts:
  1. Encapsulation
  2. Inheritance
  3. Polymorphism
The basic concepts will be discussed in with real time example next chapter.
X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now