To Refactor or Not to Refactor…

That is the question. And the answer is yes. Do it.

As we’re nearing the end of the term, and our Capstone projects are coming into something close to their final forms, I’m putting my focus and attention on refactoring. While I came into our project with knowledge of Flutter and Dart, it certainly was not advanced, and was constrained to the specific techniques taught in the Mobile Development class here at OSU. The unique requirements of our project, using Firestore in a much greater capacity, and developing on a team have resulted in a great deal of new learning.

One side effect of learning something new is that it’s not usually perfect the first time. And by not usually I mean almost never. So the code I have needs work. It’s accomplishing what it’s supposed to, but in terms of being DRY, of functions being short and doing one thing, and encapsulating code to avoid unnecessary dependencies, there is work to do. Part of the learning curve has been understanding Firestore, and the best way to write queries, and read and write data. Part of the refactoring work to be done will be to make sure I’m doing these database queries and writes consistently and efficiently. Then, having made sure that component is done well, I will take a look at the structure of my dart files, try to keep my model classes purely dart, and put other functions and classes in the most appropriate places. 

Aside from Firestore interactions, I’m hoping to make sure performance is most efficient by extracting widgets to their own classes, so that the build methods do not become over-encumbered with functions needlessly being rebuilt. Lastly, making sure conventions, line length, and comments are consistent across our program will be a priority.

While there is plenty to be done, I do find myself happy with how far I’ve come since the early days of my time here in the Online CS program. The quality between now and my first forays into programming is dramatic, and I can differentiate between quality code and poorly written code. And when I need to refactor I recognize the process for what offers – simply another opportunity to learn and improve. 

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *