Work Project Refactoring

One of my main projects at work is basically a web front end for a little bit of the data available in our main application. When I was first hired I was given my first month to go about writing this application. I did not have much experience with web development, but I had way more than anyone else at the company. I opted not to use a framework in the code and because I was new, I really did not know how to structure the code correctly or in a sufficiently decoupled way. Although I did use view templates, I did not use sufficient inheritance in the controllers or really plan out how I was going to do settings for the application. Now, the application has grown so much that making changes is becoming more difficult. I came to the conclusion that I needed to refactor my the application and this time, I would take use a framework with it.

There are a number of reasons that I need to refactor. All of the controllers now have an enormous amount of boilerplate, and because I did not make a base class for them, I have to put it in each one of them. The settings for the application feel very tacked on. I am using a JSON file to store all of the settings, but I have to duplicate the settings structure in another file in case the settings file is not available. The way I figure it, if I am going to do that amount of refactoring, I might as well make things easier on myself for future work by using a framework. I opted to use [Symfony][] because it uses the same templating language that I was already using ([Twig][], which is the same syntax as is used in a [Python templating engine that I already knew][j2]). I really did not want to have to write all of the views again. This way, I only have to write the controllers again, which needed to have more functions in them anyway.

Additionally, Symfony provides some benchmarking and performance monitoring tools, which are desperately needed with some of the pages. On several pages, there are queries that can take quite some time to complete, and I would like to see which ones need optimization the most.

This will also afford me the opportunity to add more documentation. I have docstrings on all of the methods and classes, but there are a number of things that are not methods or classes because I did not set out to make the code object oriented. Additionally, that does not document the templates at all.

I am wondering if I should paginate some of the data and have it loaded via AJAX requests so that the page can be rendered while data is being fetched. That would increase the responsiveness of the website, but I do not know anything about AJAX and I tend to shy from using Javascript where possible. As well, that is one more technology I would need to teach my coworkers in case I can no longer work on the project.

In any case, all of this is predicated upon having some time between other projects to work on this. It is almost always hard to convince management to allocate time for refactoring, but my supervisor is generally pretty ok with me spending my down time working on extraneous projects. I just need to finish up the ones with deadlines first.