Skip to main content

Programming Paradigms


Programming has evolved over the years, adopting different approaches and methodologies to solve problems.

Called programming paradigms, they influence the way developers think about and structure their code.


What is a programming paradigm?

A programming paradigm is an approach or method taken to solve a problem using programming. It determines how programs are structured and how tasks are performed.


Common paradigms

  • Imperative: Focuses on describing the steps necessary to achieve a desired state.

    • Example: Give detailed instructions for preparing a coffee or a dish.
  • Declarative: Describes what the program must accomplish without specifying how.

    • Example: Ask for coffee without giving the details of the preparation.
  • Object oriented (OOP): Bases the design on "objects" which combine data and methods.

  • Example: Imagine a car as an object with properties (model, brand) and methods (moving forward, backward which will be abstractions of the entire process).

  • Functional: Treats calculation as the evaluation of mathematical functions.

    • Example: Use a function to calculate the average of a set of numbers.

Example with JavaScript and Object Oriented Programming (OOP)

JavaScript is a general-purpose programming language that supports multiple paradigms, including OOP.

  • Objects: In JavaScript, almost everything is an object, from functions to arrays and strings.
  • Prototype: JS uses the prototype chain for inheritance rather than traditional classes. (up to es6)
  • Classes: With ES6, JS introduced the concept of classes to support more conventional OOP syntax.

Learning track

  • Objects: how to create them, access their properties, add methods to them.
  • Explore the prototype: understand how JavaScript manages inheritance and the prototype chain.
  • Adopt ES6 and classes: know how to define and use classes in JS.
  • Go further with OOP: encapsulation, polymorphism, inheritance, and abstraction.
  • Practical projects: apply OOP to real projects to consolidate your understanding. Example: create a quiz game.

Programming paradigms provide frameworks for approaching programming problems. Understanding the right paradigm for a given task can greatly facilitate the development process.

The adoption of OOP is often rejected at the beginning of learning. However, it is important to understand the basic concepts of OOP to be able to apply them correctly and also provide a deeper understanding of your languages ​​as well as others.

Once you can roughly see the paradigms, I advise you, if you have a traditional background in the web, to understand and master at least basic OOP and functional programming.