Procedural Programming in Ruby? Why is it Necessary?

Posted by Robert Shields IV on January 9, 2020

Procedural programming is a paradigm which requires a series of logical steps & sub-steps in order to solve problems using data. In Ruby, methods are used to modify the state of our programs. The data remains separate from the procedures. Knowing the procedures in Ruby is vital, this includes writing statements, manipulating arrays, writing detailed methods, hashes, etc. These are considered the building blocks for implementing logic and abstraction in Ruby. It also creates a smooth transition into Object Oriented Programming.

It’s important to have parameters so you can reuse your code over and over again. The procedure is the logic of your methods so it’s important to give detailed instructions to accomplish your task.

One of the subtle and important things to understand about procedural Ruby is the dangers of having your data separate from your methods. It can be dangerous since you can modify the data while continuing to pass it through other methods. Managing our data through arguments isn’t ideal, especially if you want to update the existing program. It keeps it from being too messy. This is where Object Oriented Programming shines.

Ruby has provided a smooth transition for understanding the basics from procedural programming into object oriented programming. It’s important to learn and understand since it also uses a procedural approach, however it’s managed within the object.