Split the Source Code
Explore how to organize Ruby code by moving routines like word_info into separate files. Understand using require_relative to include files, improving code readability, preventing errors, and facilitating reuse in other programs.
Make a separate file for word_info routine
Every time we make a change, the number of lines of code increases. We went from a few lines of code—only eight lines—to forty-five lines. The more the number of lines, the more challenging it gets to find where one or the other item is located. However, we already isolated a set of operations by grouping them in a routine.
One option that programming languages provide is to isolate the parts of the code in different files. This frees us from the need to keep in mind the dozens of ...