Skip to content
Luca Ubiali Web Developer

How to Contribute to Open Source - 8/13 - Refactor for Readability

August 20th, 2024
Continuous Learning

Episode - https://laracasts.com/series/how-to-contribute-to-open-source/episodes/8


First thing change the $step array to be its own class with typed fields and helper methods.

At the beginning use an array for speed and flexibility. When the whole logic and data structure is known, move to something more robust and easier to work with in the future. I like this two phases approach. Too often I saw code stuck in the first phase, or skip it altogether and spend too much time tackling phase two right off the bat.

And of course, having tests to back you up is critical in moving the code to a more readable format.

Not only the code is more readable, but it can also be change to follow the code style used by the package itself (for example make public fields protected and use helper methods to interact with them).