When is procedural programming used?

Programming Paradigm Concepts

Eleanor Thomas

Senior Data Analytics Engineer

Typical applications for procedural programming

  • Commonly used in general-purpose programming languages
  • Makes sense when problems naturally break down into steps
  • Great for automating data preparation processes
  • Used in building websites
  • Any kind of coding task where the problem can be defined step-by-step and broken up into subtasks

Three pictures depicting data preparation, programming websites, subtasks

Programming Paradigm Concepts

Procedural programming example

price_in_cents = 500
price_in_dollars = price_in_cents / 100

discount = 0.20
final_price = price_in_dollars * (1 - discount)
print("The final price is: $", final_price)
  • Start with the price in cents
  • Convert to dollars
  • Apply a discount
  • Print the result
Programming Paradigm Concepts

Pros and cons of procedural programming

PROS

  • Benefits modularity, reducing overall amount of code and saving time
  • More straightforward than other paradigms, accessible, commonly used with a lot of educational resources available
  • Highly flexible and appropriate for many use cases

CONS

  • Can be less secure than other paradigms due to how data is moved around
  • Code is rarely reusable between projects
  • Focus is on the operations to be done with the data rather than the integrity of the data
Programming Paradigm Concepts

Procedural programming vs. imperative programming

  • Procedural programming is imperative programming, but not all imperative programming is procedural
  • All imperative programming makes use of step-by-step instructions on how to execute
  • Procedural programming specifically makes use of procedures (or subroutines) to organize code and dictate the flow of the program

Flow chart diagram

Programming Paradigm Concepts

Let's practice!

Programming Paradigm Concepts

Preparing Video For Download...