Skip to main content

Object Oriented Programming (OOPs)- a funny starting



OOPs – Object Oriented Programming System

Object-oriented programming (OOP) is a programming paradigm that uses “Objects “and their interactions to design applications and computer programs.

There are different types of OOPs are used, they are

  • Object
  • Class
  • Data Abstraction & Encapsulation
  • Inheritance
  • Polymorphism
  • Dynamic Binding
  • Message Passing


1) Object :

Object is the basic unit of object-oriented programming. Objects are identified by its unique name. An object represents a particular instance of a class. There can be more than one instance of an object. Each instance of an object can hold its own relevant data.

An Object is a collection of data members and associated member functions also known as methods.

For example whenever a class name is created according to the class an object should be created without creating object can’t able to use class.

The class of Dog defines all possible dogs by listing the characteristics and behaviors they can have; the object Lassie is one particular dog, with particular versions of the characteristics. A Dog has fur; Lassie has brown-and-white fur.

2) Class :

Classes are data types based on which objects are created. Objects with similar properties and methods are grouped together to form a Class. Thus a Class represents a set of individual objects. Characteristics of an object are represented in a class as Properties. The actions that can be performed by objects become functions of the class and is referred to as Methods.

For example consider we have a Class of Cars under which Santro Xing, Alto and WaganR represents individual Objects. In this context each Car Object will have its own, Model, Year of Manufacture, Colour, Top Speed, Engine Power etc., which form Properties of the Car class and the associated actions i.e., object functions like Start, Move, Stop form the Methods of Car Class.No memory is allocated when a class is created. Memory is allocated only when an object is created, i.e., when an instance of a class is created.


3) Data abstraction & Encapsulation :

The wrapping up of data and its functions into a single unit is called Encapsulation.

When using Data Encapsulation, data is not accessed directly, it is only accessible through the functions present inside the class.

Data Abstraction increases the power of programming language by creating user defined data types. Data Abstraction also represents the needed information in the program without presenting the details.

Abstraction refers to the act of representing essential features without including the background details or explanation between them.

For example, a class Car would be made up of an Engine, Gearbox, Steering objects, and many more components. To build the Car class, one does not need to know how the different components work internally, but only how to interface with them, i.e., send messages to them, receive messages from them, and perhaps make the different objects composing the class interact with each other.

4) Inheritance :

Inheritance is the process of forming a new class from an existing class or base class.

The base class is also known as parent class or super class, the new class that is formed is called derived class.

Derived class is also known as a child class or sub class. Inheritance helps in reducing the overall code size of the program, which is an important concept in object-oriented programming.

It is classifieds into different types, they are

Single level inheritance
Multi-level inheritance
Hybrid inheritance
Hierarchial inheritance

5) Polymorphism :

Polymorphism allows routines to use variables of different types at different times. An operator or function can be given different meanings or functions. Polymorphism refers to a single function or multi-functioning operator performing in different ways.

Poly a Greek term ability to take more than one form. Overloading is one type of Polymorphism. It allows an object to have different meanings, depending on its context. When an exiting operator or function begins to operate on new data type, or class, it is understood to be overloaded.

6) Dynamic binding :

It contains a concept of Inheritance and Polymorphism.

7) Message Passing :

It refers to that establishing communication between one place to another.

Comments

Popular posts from this blog

Talky Messenger Documentation & Setup

( Github ) Just created a chat app that runs in Node and Socket. the attempt was worthy. Talky is a messenger app built with Node, Express, Socket, Angular & Bootstrap. It's like a server-client structure. (But obviously not like the one we done at OS lab using shared memory). It has a broadcasting structure. Talky does not keep a log on chat. i.e., It doesn't have a memory or database. When we close the browser window, chat history is lost. There I also added a basic console, protected by a password, to send real-time notifications to active clients. The name 'Talky' was suggested by a friend of mine. (hey, thank you for that. The fact is that I am not really good at naming...😝) What if sometimes your college blocks WhatsApp? Try Talky. ( There is also a website on internet in the name of 'Talky' which has no connection with this one. ) Download Talky Messenger To use Talky, all you need is 3 things: Node server Source code

Repairing my keyboard gone wrong and then right.

Few months ago I tried to repair an old unused keyboard. I opened it cleaned and put everything back in place. But didn't work. Thinking it has met it's end-of-life, I gave it to my sister's daughter, 2 year old Komal. She went hard with it. Once she even thrown it. To my surprise, after a few throws, it's now working properly 🙆.

How to pass variables to res.render() in Node.js

I was trying to figure out how to render a view inside a view, as I was stuck with this issue. Horrible Effects of Misplaced Extensions ;) I was using Node.js platform with ejs template engine. My index.ejs file has an included header.ejs file. Everything works well except that I can't pass values to the variable status in header.ejs. Here is my abstract code... index.ejs header.ejs app.js The most funniest solution ever! The solution is as easy as this. Just remove .ejs extension from the include command. I spent at least an entire night to figure it out.