Posts

Showing posts from April, 2021

What is the difference between definition, declaration and initialization?

I will answer this question in a general and complete way and not with respect to any programming language There is a hell of a lot of confusion between declaration, definition, and initialization. Sometimes they all look similar and sometimes completely different. Before understanding the differences, It is very important to be aware of two things: The difference between declaration, definition, and initialization varies from one programming language to another. Each programming has its own way of doing these three things. The “thing” which you are defining, declaring, or initializing also affects the difference between the three of them. That “thing” can be a variable, a class, or a function. All of them have different meanings of definitions, declaration, and initialization. Once we are aware of the above two things, most of the doubts get cleared and we stop seeking exact differences because it’s not there. In general terms ( irrespective of any language or “thing”) The declaration...

Object vs Instance - What's the difference?

Object-Oriented programming can be a bit confusing at times as there are concepts with very minute differences. The worst thing is that the more you read, the more you get confused as 100 people have 100 interpretations of the same concepts. When you can verify something physically and explain it in the simplest possible explanation, that concept can be said to be cleared. Coming back to the question, Objects and Instances are almost similar and are often used interchangeably but with a small difference. Let's take a Story. Suppose You are God and You are given the task to make a new species called  Males.  So you start designing your species.   All the males will have hands, legs, eyes, nose, etc. These features/states can be called attributes/properties . All males can run, walk, talk eat, etc. These are the behaviors/functions of males and can be called Methods . Once you have designed the properties and behaviors of your new species, Your class is ready. So basically ...