FMTechnical notesPortfolio
Back to the blog

Fundamentos · Beginner

Programming fundamentals: think before writing code

Programming is not memorizing commands. It is representing a problem with data, rules, and small decisions that people can read and computers can execute.

After reading this
  • Separate data from behavior
  • Recognize sequence, decisions, and repetition
  • Design single-purpose functions
01 / 03

The smallest model

Every program receives information, transforms it, and produces a result. Write those three parts before choosing a language.

A variable names data; a type limits meaningful operations; a function encapsulates a transformation.

  • Input: what the program needs.
  • Process: the applied rules.
  • Output: the observable result.
js
function calculateTotal(price, quantity) {
  const subtotal = price * quantity;
  return subtotal * 1.21;
}
02 / 03

Control flow

A condition chooses a path. A loop repeats a rule. Use them when the domain needs them, not to show that you know the syntax.

js
function canEnter(age, hasTicket) {
  if (age < 18) return false;
  return hasTicket;
}
03 / 03

Functions people can understand

A good function has a concrete name, explicit inputs, and a predictable output. If it needs a very long explanation, it probably does more than one thing.

Logic flow● interactive
INPUTRULECHECKOUTPUT
Practice

Practice

Write a function that receives prices and returns only those above 10,000 after tax.

Show a hint

Separate the tax calculation from filtering. Two small functions are easier to test.