Procedural vs Object-Oriented Programming

A Procedural programming is essentially a list of instruction that execute one after the other from the top of the …

A Procedural programming is essentially a list of instruction that execute one after the other from the top of the file and working down.

Object Oriented Programming, on the other hand, are built around object, you can think about object about things that exist in the real world.

Example : If you were going to build a clothing store, the store itself would be an object, the item in the store like the shirt and jean would also be an object, like the salesman or cash register.

An object oriented program would focus on the individual characteristic of each object and what each object can do.

So an object has 2 essential parts : Characteristic & Action.

Another way to think about characteristics and actions is in terms of English grammar. A characteristic would be a noun. On the other hand, an action would be a verb.

Let’s pick something from the real-world: a dog. A few characteristics could be the dog’s weight, color, breed, and height. These are all nouns. What actions would a dog take? A dog can bark, run, bite and eat. These are all verbs.

The characteristic and actions have specific names in OOP,

  • Characteristic : Attributes
  • Actions : Methods

Object vs Class

The t-shirt object have the same attributes and methods only the value of those attributes differs.

They both have a price, style, color …

It’s like they came from the a blueprint, a generic shirt consisting of all attributes and methods.

This generic version of an object is called a Class.

From this Class you can create specific object from the class over and over again

Keep reading

More >