Procedural Ruby. Is it a Metaphor for life?

Posted by Robert Shields IV on January 28, 2020

Well, lets look at the definition of a metaphor. A metaphor is a figure of speech in which a word or phrase is applied to an object or action to which it is not literally applicable.

So lets look at Procedural Ruby and compare it to life. How do they match up with one another? When I’m writing methods, I create a series of steps to complete certain task by using data structures, and conditionals, such as if/else statements Think of your daily activities; Getting ready for school, cooking a meal, driving to work, etc. Just like procedural ruby, these actions require steps and conditions to complete any given task. For example, Driving from point A to point B; you’d create detailed step by step instructions to drive to your destination. You might have to add conditionals for things like “What if you run into traffic?” , or “What if I run out of gas, and the car breaks down?”.

Similar to the procedures in Ruby you might need to go a level deeper and explain the basics of your task, such as driving, cooking, or brushing your teeth

And sometimes you even need to explain precisely how the steering wheel or the gas pedal works.

def Drive might take in an argument of (vehicle), but what is a vehicle? You have to make that assumption that computers might not know how to think on their own, which is where the user comes in to create those magical conditionals, arguments, etc. Once you’ve got that all described in exacting detail, you might need to customize that for a specific person or situation.

def Drive_to_work (person) if person == Mary take backroads elsif person == Robert take freeway else puts “You cant drive” end

So you can make a strong case that life and procedural ruby are similar in many ways. We use various condions everyday based on what happens throughout our daily lives. We can treat our code the same way, since there will be many situation where our code will be applicable to one situation, but not others.