Object -Oriented Programming

How did we form programs till now and how you might prefer to do so from now on: The (many) growing circles example.

 

Object- oriented programming (that is, programming that uses objects and classes) is a different way of describing a problem. This approach is, in fact, more intuitive to the way we (non-computers) perceive the world around us. With object-oriented programming, a program will create, use and manipulate objects.

So, what is an object?

You can think of an object as an entity, something that can exist on its own sake. A dog, a car, a circle are all objects. (I will use circles from now on)

 

But what is it that makes an object? An object has its own characteristics and its own behaviors. That is, there are things that describe an object and things that an object can do. So, an object has its own variables and its own functions, all these go together to make an object.

 

Our circles have an x_pos, a y_pos, diameter (the variables) and can be drawn, can grow, move etc (the functions). We can have many circles in our program, all of which will belong to the one circle "family".

What is a class?

A class is a blueprint for objects. It is the model out of which you are making individual objects of the same kind, an abstract representation of a particular family of objects.

 

You can think of a class as a data type for your own objects: when you write a class of your own, you create a type of your own that can be used to create new "variables". We refer to these complex variables as objects or instances of a class.

 

In order to use circle objects in our program, we need one circle class that describes what a circle is.