abstraction, encapsulation, inheritance, and polymorphism.
Abstraction is the concept of describing something in simpler terms, i.e abstracting away the details, in order to focus on what is important (This is also seen in abstract art, for example, where the artist focuses on the building blocks of images, such as colour or shapes). The same idea translates to OOP by using an inheritance hierarchy, where more abstract concepts are at the top and more concrete ideas, at the bottom, build upon their abstractions. At its most abstract level there is no implementation details at all and perhaps very few commonalities, which are added as the abstraction decreases.
As an example, at the top might be an interface with a single method, then the next level, provides several abstract classes, which may or may not fill in some of the details about the top level, but branches by adding their own abstract methods, then for each of these abstract classes are concrete classes providing implementations of all the remaining methods.
Encapsulation is a strategy used as part of abstraction. Encapsulation refers to the state of objects - objects encapsulate their state and hide it from the outside; outside users of the class interact with it through its methods, but cannot access the classes state directly. So the class abstracts away the implementation details related to its state.
Polymorphism is a long word for a very simple concept.
Polymorphism describes a pattern in object oriented programming in which classes have different functionality while sharing a common interface.
The beauty of polymorphism is that the code working with the different classes does not need to know which class it is using since they're all used the same way. A real world analogy for polymorphism is a button. Everyone knows how to use a button: you simply apply pressure to it. What a button "does," however, depends on what it is connected to and the context in which it is used — but the result does not affect how it is used. If your boss tells you to press a button, you already have all the information needed to perform the task.
In the programming world, polymorphism is used to make applications more modular and extensible. Instead of messy conditional statements describing different courses of action, you create interchangeable objects that you select based on your needs. That is the basic goal of polymorphism.
Inheritance enables new classes to receive—or inherit—the properties and methods of existing classes. In previous articles, you learned that an object is a self-contained component that contains properties and methods needed to make a certain type of data useful. You also learned that a class is a blueprint or template to build a specific type of object and that every object is built from a class. Inheritance is a way to express a relationship between blueprints (classes). It's a way of saying: I want to build a new object that is similar to one that already exists, and instead of creating the new class from scratch, I want to reference the existing class and simply indicate what's different.
Using two concepts of inheritance, subclassing (making a new class based on a previous one) and overriding (changing how a previous class works), you can organize your objects into a hierarchy. Using inheritance to make this hierarchy often creates easier to understand code, but most importantly it allows you to reuse and organize code more effectively.
Using an ORM save a lot of time because :
DRY : You write your data model in only one place, it's easier to update, maintain and reuse the code.
A lot of stuff is done automatically, from the database handling to I18N.
It forces you to write MVC code, and in the end your app is cleaner.
You don't have to write poorly formed SQL (most Web programmers really suck at it, because SQL is treated like a "sub" language whereas it's a very powerful and complex one)
Sanitizing, using prepared statements or transactions are as easy as calling a method.
Using an ORM is more flexible because :
It fits in your natural way of coding (it's your language !)
It abstracts the DB system, so you can change it whenever you want.
The model is weakly binded to the rest of the app, so you can change it or use it anywhere else.
It let you use OOP goodness like data inheritance without head ache.
But ORM can be a pain :
You have to learn it, and they are not lightweight tools;
You have to set it up. Same problem.
Performances are ok for usual queries, but a SQL master will always do better with his little hands for the big dirty works.
It abstracts the DB. While it's ok if you know what's happening behind the scene, it's a trap for the noobs that can write very greedy statements, like a heavy hit in a for loop...