It is said that in order to internalise the basics of programming you need, first and foremost, learn to think like a programmer. That is to say, not only to programme by pressing keys, but to adapt our perspective and our mind to a way of proceeding that distinguishes a programmer from a non-programmer. To develop a programmer's mind, you have to master what we call programming logic.
The logic of programming is nothing more than knowing how what we program works and why, which gives us a more global, accurate and informed vision of this field. Are you studying or considering studying a programming language? This post is for you! Here we'll give you tips to help you get the hang of programming logic and teach you key tips to build your basic knowledge.
How to improve my understanding of programming logic? A few tips
Rome was not built in a day, and the same goes for programming logic. We cannot expect to become expert programmers overnight., Nor is it easy to start building the house from the roof up. Nor is it easy to know where to start in order to improve our understanding of the intrinsic logic in all the programming languages.
That is why at Euroinnova we are going to give you a couple of tips to help you adopt the right mindset when facing this challenge:
Regular programme
Practice makes perfect, This principle is applicable to any skill we want to master. We must embrace programming as a habit of learning and practice in our lives, and so it is imperative that we intersperse it into our daily routine if we are to internalise its logic.
Segment problems into smaller units
That is, breaking down a large task into smaller ones. In this way, we can proceed in a prioritised order to gradually move towards the completion of an entire project. In addition, this helps us to focus on more manageable problems and to make our code cleaner.
Take a look at the code of other programmers
The best tool for learning programming logic is looking at other programmers' code and contrasting it with our knowledge. On the Internet there are many programming experts who have left their mark on websites, applications, video games... whose code you can learn from to improve your own.
Be aware of your level
If you are starting programming, you should have realistic expectations. Programming is a discipline of cumulative learning, In other words, you are unlocking new skills as you have already acquired others. That is why it is important that you know how to assess your own skills, how far you can go and how far you cannot go at the moment. In this way, you will be able to find resources adapted to your training needs and build up a knowledge base gradually but effectively.
Importance of knowing programming logic
Imagine that we are building a house and we put about twenty capuchin monkeys to hammer, lay bricks, bind them together and assemble structures. It is possible that, if these capuchin monkeys have automated these tasks, they will successfully build the house. But, Do they really understand why they do what they do? If the procedures by which they build the house were to change, would they be able to adapt?
We don't want to be capuchin monkeys, but people with a critical sense and cognition. Learning programming logic means learning how programming languages work and, above all, why they work as they do. This skill is vital to incorporate new knowledge, to draw lessons from our programming experience, and to know how to deal with solving problems as they arise in our day-to-day work as programmers.
Key concepts
To be able to unravel the logic of programming and start thinking like a programmer, it is necessary to be clear about a series of elementary concepts, which we will explain below:
Variables
The variables are containers that store values that can change during program execution. In most programming languages, variables have a unique name and an associated data type that determines what kind of values they can store.
Example in Python:
# Variable declaration and assignment
age = 25
name = «John».»
height = 1.75
# Variable update
age = 26
Variables are used to store data. As shown in the example, age, name and height are variables that contain information about a person. Variables may change value during program execution; for example, the variable age is updated from 25 to 26.
Functions
Functions are blocks of code that perform a specific task. To do this, input data is introduced, and the function returns an output. They allow code to be reused and make it easier to organise and maintain.
Example in JavaScript:
// Definition of a function
function sum(a, b) {
return a + b;
}
// Function call
let result = sum(3, 5); // result = 8
The function sum in JavaScript is a block of code that performs a specific task: it adds two numbers together and returns the result. Functions allow you to encapsulate logic and reuse it in different parts of the program. In this case, sum accepts two arguments (a and b) and returns the sum of these two values. By calling the function with concrete values (3 and 5), the desired result (8) is obtained, demonstrating the usefulness of functions for performing calculations and repetitive tasks.
Data types
Data types define the type of value that a variable can store. Common types include integers, floats, strings, booleans, among others.
Control structures
Control structures control the flow of program execution. They include conditional statements (if-else) and loops (for, while). With them, we can repeat actions as long as certain conditions are met.
Example in Java:
// Example of conditional structure
int age = 20;
if (age >= 18) {
System.out.println(«You are of legal age»);
} else {
System.out.println(«You are a minor»);
}
In this example we have used a conditional structure if-else to make decisions based on a condition: if a person is 18 years of age or older, he or she is considered an adult; otherwise, he or she is considered a minor.
Classes and objects
Classes are templates for creating objects. They define properties (attributes) and behaviours (methods) common to a set of objects. Objects are instances of a particular class. Each object has its own values for properties, but shares the same methods defined in the class.
Example in Python:
# Definition of a class
class Persona:
def __init__(self, name, age):
self.name = name
self.age = age
def greet(self):
print(«Hello, I am», self.name)
# Creation of objects (instances) of the Person class
person1 = Person(«John», 25)
person2 = Person(«Mary», 30)
# Calling a method of an object
person1.greet() # Output: Hi, I'm John
person2.greet() # Output: Hi, I'm Maria
It defines a class called Person which encapsulates information about a person, such as name and age, as well as associated behaviours, such as greeting. Objects (person1 and person2) are instances of this class, which means that they inherit their attributes and methods. Calling each object's greet method executes the code associated with that method, allowing each object to perform specific actions.



