coala: Some GUI Enhancements and some refactoring.

Quite some time has passed since my last blog post. So what have I been upto…

Refactoring

Coala followed a brutal object oriented programming approach initially. While working on it we have realized that a lot of the elements involved in coala don’t need to object and can rather be refactored into a set of functions. I particularly worked on refactoring to such objects. The SectionExecutor and BearRunner:

  1. SectionExecutor: This object was responsible for running sections in coala. Initially we used to instantiate the object with the required parameters to execute a coala specific section. Things have changed now. It has been refactored to a set of functions with the execute_section function calling other functions to execute a section. Also it has been renamed to Processing to represent a more clear name.
  2. BearRunner: This was an object that inherited from the multiprocessing.Process object. This object was responsible for running Bears. We created multiple objects and ran them in parallel depending on how many processes a machine could handle. Its not an object anymore but again a set of functions. And the run method of the earlier process is just a method now and is passed to the Process object as the target function to achieve the same goal.
  3. Some other changes: This includes passing the interactor object as a set of callbacks instead of passing the whole object to any method or another entity.

Why was the refactoring necessary?

Earlier coala was just a single executable having a single main script and everything was tightly integrated together and worked. Now with the development of a GUI interface and a Gedit plugin it needs to be more generic. A lot of the times in development of other frontends for coala we as developers need to access specific functions instead of complete objects. Hence the refactoring was necessary.

Progress with GUI

Admittedly GTK has a steep learning curve especially when you are using it in python. As most of the documentation available is naturally for C. Now I have decent hang on layouts and have been able to come up with a hacky configuration file editor for coala.

The next step with the GUI is to execute coala. We want coala to execute when the following things happen:

  • User opens the project.
  • User changes a setting.
  • User changes a file in the project.

This seems very simple on the face of it but if suppose a coala execution is already in process and one of the above three things happen we want to kill that execution and spawn another coala execution. For this we need to have coala as cancellable. It seems very simple but due to the multiprocess nature of coala its not as simple. To gracefully exit coala we are looking into some approaches.

What’s next?

  1. Make coala cancellable. This is especially tedious because we want to have it multiplatform instead of having different handling for different platforms.This is top priority as of now
  2. Execute coala from the GUI.
  3. Present the results to the user in the results tab of the GUI.
  4. Setup a continuous integration framework on mac osx environment for coala. We currently test on windows and linux.

UT

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s