programming paradigms

What are the software development paradigms, the styles or types of programming that we can use when developing applications. Sometimes a language can allow you to organize code with several paradigms at the same time.

In this article we are going to see the different programming styles that we currently find in the software industry. In a past article we briefly talked about the , highlighting the high and low level ones. Now it is not about analyzing the language itself, but the paradigm that they implement, that is, how we will have to program with them.

The idea is, as always in this manual, to have a global vision about what we can find on our way as programmers, although to tell the truth, practically entire books could be filled with each of these paradigms.

What is a programming paradigm

The Programming paradigms are styles that are followed when programming software.. As style we can refer to many things, for example the control structures that we have been using, or the way of structuring the programs, even the elementary pieces that they will have.

Throughout the history of software, they have incorporated different paradigms that they were adding better code organization possibilitiesproviding greater clarity and the possibility of creating the software by composing it with smaller pieces and therefore less complex. Programming languages ​​over time have been born with the paradigm that was most established at the time of their creation, although many have evolved and incorporated the possibility for programmers to use other programming styles or paradigms if they wished. This is how most languages ​​currently implement various types of programming, which is sometimes known as multi-paradigm.

The types or techniques of programming are quite varied, although many of the readers may only know one method to carry out the programs. In most cases, the techniques focus on modular programming and structured programming, but there are other types of programming. We will explain them throughout the article.

The most widely used programming paradigm or style today is imperative programming in which we carry out algorithms with actions that are executed one after the other. In this imperative way we tell the computer, step by step, all the things it must do to solve a problem. Imperative programming has several programming styles, such as structured or object-oriented. In contrast to it we have the functional or logical paradigm. We will talk about all of this below.

Structured Programming (SP)

Structured programming is composed of a set of techniques that have evolved considerably increasing the developer’s productivity and the possibility of structuring the program in small pieces how are the functions Thanks to them, it was possible to reduce the debugging and maintenance time of the software.

See also  First steps with Hugo

Before structured programming, programs were huge lists where there was no separation of the problem, just lines of code one after the other. The programs were executed sequentially, but the programmer could at any given moment send the execution flow to another line of the list, generating flows that were not very predictable and not very intuitive.

This structured programming uses a limited number of control structures and creates a well-defined flow of software execution. This facilitates the understanding of the programs, considerably reduces errors and facilitates the extensibility and adaptability of the code.

This technique incorporates:

descending design (top-dow): the problem is broken down into stages or hierarchical structures. Each one of the elements of that hierarchy has a responsibility, the pieces at the top of the hierarchy are more general and those at the bottom are more specific.

Abstract resources (simplicity): consists of breaking down complex actions into simpler ones capable of being solved more easily. We can start by designing the highest, most abstract structure, relying on subprograms (often called functions) that we imagine exist, even though they are not yet developed. As the subprograms develop, they can be supported by others, up to elementary and very specific levels of complexity.

basic structuresThere are three types of basic structures:

  • sequential structures: each action follows another action sequentially. The output of one action is the input of another.
  • selective structures: in these structures the conditions are evaluated and depending on the result of the same, some actions or others are carried out. Logical expressions are used. These types of structures are often referred to as conditionals.
  • repetitive structures: are sequences of instructions that are repeated a certain number of times. Repeats are commonly known as loops.

The main advantages of structured programming are:

  • Programs are easier to understand
  • Test complexity is reduced
  • Increases programmer productivity
  • Programs are better documented internally.

A program is structured if it has a single entry point and only one exit pointthere are “1 to n” paths from the beginning to the end of the program and finally, that all instructions are executable without infinite loops appearing.

modular programming

In modular programming we have different modules of which a program is a part. According to the author they can refer to modules as functions, or as different code files.

If we understand modular programming as the fact of being able to work with functions, we could say that it consists of several sections divided in such a way that they interact through calls to procedures, which make up the program as a whole.

See also  How to make a SQL to subtract inventory quantity when generating the sale

Procedures and functions are the same thing. Although there are languages ​​that distinguish between them, saying that procedures simply do things and functions do things and return values. But this is something proper to language. We recommend initially understanding them as synonyms and, if our language makes a distinction, then knowing what meaning they have given to do things correctly.

In modular programming, understood as divided into functions, the main program coordinates the calls to the child modules and passes the necessary data in the form of parameters. In turn, each module can contain its own data and call other modules or functions.

Nevertheless, we can also understand modular programming as that which is composed of modules. Before modular programming, a program could have hundreds or thousands of lines in a single file. However, moving through such a long file and finding what we want is very complex. For this reason, languages ​​currently allow program code to be divided into different files, which have control units related to each other.

Within a module (an independent file of the many that can compose a program) we can find artifacts such as classes, interfaces (which we are going to talk about next) or even simple functions. There will be a main module that is the one that starts the execution of the program, which will be supported by secondary modules with pieces of software that it needs to be able to carry out its tasks.

Object Oriented Programming (OOP)

This is a technique that considerably increases the simplicity of the code, creating structures called classes that allow us to group bounded functionalities and well defined. Thanks to object-oriented programming, it is usual to acquire greater speed of development of programs thanks to and some much higher degrees of code reusability. However, the most important thing is that it allows us a organization greater, which ends up making it possible to develop more complex programs.

Before object-oriented programming, it was said that a program could be as long as 100,000 lines of code before it became unmanageable. Thanks to object-oriented programming, it is possible to reach 1,000,000 lines of code without everything becoming chaotic. These are numbers just to give us an idea of ​​the magnitude of the improvement, but don’t take them literally. Of course, the ability to do good software design also influences a variance in these numbers, so it depends a lot on the programmer or development team.

See also  First letter of a paragraph in bold only with inline CSS

We usually explain the concept of object-oriented programming by looking at the real world. In our lives we find systems that are made up of many parts (for example, the human body made up of the heart, brain, limbs, etc.) that collaborate with each other to perform their functions. Then, each of those pieces, like the brain, can be made up of different elements, like neurons and nerve connections. In turn, these pieces are made up of others and so on until we get to the less complex ones that we could consider to be cells.

Understanding this we can say that in the world of object-oriented programming we also build systems that have objects that collaborate with each other to perform the functionalities of the applications. Some objects are supported by other more specific ones, until we reach objects that are only supported by basic elements such as numbers or character strings. However, the object-oriented paradigm goes much further and this is just a simplification to understand the programming style.

  • The main element of object-oriented programming is the class, which consists of a definition of what the objects of a type will be like. The object would be a concrete instance of the class.
  • The class is a set of properties and operations on them. All objects will have values ​​in their properties, specific data and on them we can invoke their operations.
  • The classes have a structure and together they are part of an organization that solves more global problems. The same goes for objects generated from those classes.
  • An object contains various well-structured data and may or may not be visible depending on the class definition made by the programmer. You can also have operations that are visible from the outside and others that are only private and executable from the inside.
  • We can understand a class as a type of element. Objects as elements of a type. Although in object-oriented programming there are also other artifacts such as interfaces, which also allow us to define element types.

La and el are some of its main characteristics and for this reason we will dedicate an article later exclusively to dealing with these two terms.

At .com we have published a complete manual to explain what the .

concurrent programming

This type of programming is used when we have to perform several actions to…

Loading Facebook Comments ...
Loading Disqus Comments ...