Object-Oriented Programming

Object-Oriented is a hard concept to understand. In this handout, I will try my best to explain it and give real-life examples.

Watch the short video below to get some ideas of why we need object oriented programming:

Class

Class is the core of object oriented programming. Class in programming is like the “concept” in your mind. For example, You have a concept of car, you know a car can have different colors, different models. You know a car can start or move.

Instance

Instance is when you see a car, or someone tell you about a car, After you know the color and model of the car, you created an “real car” in your mind based on the “concept car”. You can create many “real car”s in your mind based on the same concept. The same process in programming is you create a instance based on a class. You can create many instances based on same class.

Property (or Attribute)

Properties are the color and model of the car. Although they are all cars(same concept), but different cars can have different color(different property). Also, different cars can have same properties, for example you see two exactly same car driving on road, they have the same properties but the car itself is not same.(because they are two cars!) Same in programming, properties are variables inside an instance.

Method

Methods are what a car can do, for example a car can start or move. But how fast a car moves is based on it’s properties. Same in programming, methods are functions inside an instance, methods can access the properties of the instance.

The Truth of Value Type

Have you ever wondered, what really is a variable type? Can I make a value type of my own?

The answer is, all values are an instance of a class, and the value type, is the name of that class.

Next: How to Use a Class

https://img.shields.io/badge/By-Pegasis-green.svg