Object-oriented programming paradigm principles?

object-oriented programming paradigm, object-oriented programming

Many people often confuse Object-Oriented Programming Paradigm with Object-Oriented Programming Language. They are both popular topics among programmers. There are a plethora of books on the topic and articles that you can easily find on the internet.

You can find explanations of characteristics, examples, and an overview of what is object-oriented programming in several articles. However, It is difficult to find good explanations about the object-oriented programing paradigm. You can find two examples of those articles here and there.

Do you want to get a deep understanding of the fundamentals of the Object-Oriented Paradigm?

If your answer is yes, keep reading and you will get to the bottom line of this important paradigm.

The key to having a great understanding of object-oriented programming is this: focus on the paradigm and not in a particular programming language.

In this article, I’ll follow one of the most important authors in the topic, Bertrand Meyer. I’ll guide you through what I believe is the key to get a fundamental understanding of the Object-Oriented Programming paradigm.

Problems that the Object-Oriented Paradigm address

The whole paradigm goal is to write better software, to write code of higher quality. So let’s analyse the paradigm as a method or tool to write better software. Also, as a way to improve the quality of the software we are creating.

Always ask yourself if what you are doing improves the quality of the software you are creating or not. 

Meyer explains the criteria of object orientation through three categories:

  1. Method and language. Here he describes all the characteristics of the method and the language. It also includes all the basic concepts of an Object-Oriented Programming Language. A sample of the main concepts are: Class, Objects, Assertion, Information Hiding, Genericity, Inheritance, Polymorphism, Dynamic Binding.
  2. Implementation and environment: It is related to the features that a development environment need-to-have to support object-oriented software construction.
  3. Libraries: These are pieces of reusable software. You suppose to have good libraries you can use through the development and the ability to create new ones.

As you can see, Object-Oriented Programming is a paradigm to develop software, IT IS NOT a programming language. 

I want to make it clear to you that Inheritance, Polymorphism, Genericity, etc. are characteristics of an Object-Oriented Programming Language. They are not the paradigm, they are not the principles of the paradigm.

The three previous categories will guide us in writing quality software.

Software products must have four desirable qualities according the object-oriented paradigm

  • Correctness and robustness: We define correctness as the ability of the software to performs the task according to the specifications. Robustness is the ability to react well in all situations. 
  • Extendibility and reusability: These two characteristics are based on the principle that software must be easy to modify. Also, you must be able to reuse parts of the software to build new functionalities. 

Most of the characteristics of the Object-Oriented Programming Languages guide us through the process of software development. Through this process, we have to achieve the 4 previous desirable qualities of any software product.

Think yourself a bit about it, through the following questions:

  • How will you feel if you make an online bank transaction in your account and the bank deducts the double instead of the exact amount? (Correctness)
  • How will you feel if after you create a transaction, all the information you already entered is lost? So now you have to enter all the information again? (robustness)

Similarly, you can ask yourself other questions regarding software products. The answers will lead you to the concepts of extendibility and reusability. 

We can summarise the last two concepts in a new one: modularity.

Modularity

Modularity is one of the main desirable characteristics that our software must-have. We can describe this characteristic from several points of view. Here I only refer to the principles:

  • The Linguistic Modular Units principle. “Modules must correspond to syntactic units in the language used.”
  • The Self-Documentation principle. “The designer of a module should strive to make all information about the module itself.”
  • The Uniform Access Principle. “All services offered by a module should be available through a uniform notation, which does not betray whether they are implemented through storage or through computation.”
  • The Open-Closed principle. “Modules should be both open and closed.”. Open means that you can extend it, and closed means that can be used by other modules.
  • The Single Choice principle. “Whenever a software system must support a set of alternatives, one and only one module in the system should know their exhaustive list.”

Reusability

Reusability has many different explanations and approaches. However, we can keep it simple to get an informal understanding.

We must write reusable codes. This means that anytime we are writing code, we must do it in such a way that someone else can use our code.

As a very simple example, we are writing code that allows us to represent a date in different formats. We should write that code in a way that we can use it in several projects. Consequently, other developers must be able to use it in their projects.

It is an easy concept to understand, not so easy to implement. 

Remember this: “Reuse Path principle: Be a reuse consumer before you try to be a reuse producer”.

As you could see until here, there is a lot behind the Object-Oriented Programming Paradigm. In this article, I’m barely scratching the surface. 

My goal is to show you that Object-Oriented Programming is a paradigm, it is more important than to learn a programming language.

Classes, objects, genericity, inheritance, polymorphism are part of the technique. We must use them to achieve the higher principles of the paradigm, to create high-quality software. All of them are means to achieve an end. They are not the end itself.

You can find plenty of information about this programming paradigm in my favourite book about the topic. It is one of Bertrand Meyer’s books.

Related topics:

This post may contain affiliate links to sustain our blogging endeavours. If you use these links to buy something we may earn a commission at no extra cost for you. We only recommend what we already used ourselves and got a positive result.