Everything in life that is structured will follow a blue print or pattern that is based on proven design methods whether they are concept based or concrete. That is to say the result is tangible.
Software development regardless of language too has patterns and principles which if effectively applied to your solutions will result in code that is maintainable, testable and ultimately flexible enough to change as scope or business requirements evolve.
Always remember that software development is an iterative process, your job is never done.
These days we as software developers are spoilt with access to information on the internet detailing different design patterns and principles. It would be very presumptuous for any developer to assume they understand every pattern or principle however there are some foundational points that I personally feel every developer should be au fait with or at very least have a functional understanding thereof.
Object-oriented programming (OOP) is a programming language model organized around objects rather than “actions” and data rather than logic.
In all literature I have seen surrounding object orientated programming these 3 points always come up and are the foundation or “Pillars” of Object Orientated Programming. I share the personal view of Scott Allen that encapsulation is the primary pillar as without encapsulation we could never build applications on a large scale.
Encapsulation is the primary pillar of object-oriented programming, and most classes and training tend to overemphasize inheritance and polymorphism as being more useful than they really in day to day programming. ~ Scott Allen
Encapsulation is simply data hiding where by your classes encapsulate their internal state and complexity, this means when building your solution you only need to know about your current cognitive load as the encapsulated state will look after itself. The only access to the state (the data) would be though well-defined functions on the class or property setters. The constructor is responsible for setting the property values on instantiation so they are in a useful state when you go looking for them.
Class inheritance allows developers to create new classes that reuse behaviour (functions and properties) from their base classes. The class that is inheriting from a base class (or classes) is called a derived class.
Inheritance leverages re-use of existing code classes, this results in code that is easier to maintain and faster to develop.
If the word is broken in half; “Poly” – means many and “Morphism” – means to change. So “Polymorphism” means having many forms. In OOP polymorphism can be expressed as ‘One interface, multiple functions.’
The following are key points that build on our Pillars of OOP and are of critical importance to produce solutions that are of high quality.
Abstraction is not a pattern but rather a principle and many developers don’t consider abstraction a pillar however this is opinion based. I am of the opinion that it’s a pillar as classes with high cohesion are far simpler to test and maintain.
In computer programming, cohesion refers to the degree to which the elements inside a module belong together.
Abstraction in terms of class files is to simplify them to have a high level of cohesion. Simply put this means the properties and methods directly relate to the class you are building.