Refactoring your code
There was once a time when I had a deep affection for mathematics. I think we fell apart sometime during college but my quest to learn programming has renewed this relationship.
A major concept in computer science that I’m still getting a hang of is refactoring. It’s very similar to factorization in mathematics where you have an expression that you want to reduce to “basic building blocks”. E.g. if “x = a + b + c” and “y = a + b” then you can factor “x = y + c”.
This same concept lends itself to computer programming by the name of refactoring. Similarly this process involves rearranging a program to facilitate code re-use and improve the readability of your code.
Here’s an example from today. I’m working on a procedure “add_page_to_index” that takes three inputs and updates the index to include all of the words found in the page content by adding the url to the associated word’s url...