#WSQ03 – Object-Oriented basics and a pie

I like pies, everyone likes pies.

Here’s a photo of some pies:


But this post is not about pies, it’s about A PIE.

A PIE is an easy way to remember the 4 more important concepts of OOP.

A: Abstraction.

Abstraction means that in object oriented programming we need to abstract real world objects intro a simple concept, considering only the more essential behaviours and attributes to define that object in a general way.

P: Polymorphism.

This term refers to the fact that in Object Oriented Programming we can have the same Interface for different Objects. For instance, the plus sign, when used with number, we add these two number, and when used with strings it concatenates these two strings.

I: Inheritance.

This means that a class can inherit methods, attributes and fields from another class, and with this you are able to describe a general concept, like mammal animals, they share common characteristics, and then you can create a human class, that inherits from the mammal class, so that it is able to produce milk, but then you can add more specific behaviours to that class, like talking and stuff.

E: Encapsulation.

The idea behind encapsulation is to be able to think about objects as a black box, in which you don’t care how it works, but you care about what it does. Imagine you are using objects and you decide to change the inner behaviour of the object, if there were not encapsulation you would have to do changes wherever you used that objects, but with the encapsulation you can change the behaviour, not affecting anything outside the class of these objects.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s