OOP basics

This a class with the basics of OOP for engineering 42.

This class will cover:

  • 4Pillars
    • Abstraction
    • Encapsulation
    • Inheritance
    • Polymorphism

Other learning objectives:

  • Git +GitHub.
  • Documentation.
  • Best practices of organisation.

Definitions

class ()

A class is an essential part of OOP. is a collection of methods. groups a bunch of methods. Classes are the cookie cutters/blue print for objects/instances of a class.

(self)

Self refers to the instance on which the method is being called.

Instance of a class

It is a specific example of class. It is not the class. Occurence of a specific class.

Methods

Are functions that can be used by/on objects of a specific class.

Abstraction

Is hidding complexity from the user and exposing only useful/ necessary parts to get something done.

An example would be turning on a microwave using the start button. We don't need to know about the particle vibrations and resonance. We just need to know our food will be warm.

Inheritance

The ability to inherit behaviours and characteristics from a parent class.