MesquiteProject / MesquiteCore

The core Mesquite repository
GNU Lesser General Public License v3.0
98 stars 27 forks source link

Lite Refactor of PhoneHomeThread #95

Open willpatterson opened 4 years ago

willpatterson commented 4 years ago

This is an example of the initial lite refactoring that I think we should start with to improve the stability and readability of Mesquite. I am new to the codebase so please let me know if I am missing something here

Heres a short summary of the changes made:

1) formatted using the default Eclipse formatting tools This added @Override annotation and explicit imports, shortened some lines where it could, and formatted block comments. I think it is a good idea to use the default Eclipse formatting tools going forward to keep the codebase consistent, which makes it easier to read

2) javadoc comments I've added javadoc comments to the methods so reading the code in an IDE or javadoc browser is easier. It appears that there is some convention with the long /*---------*/ comments. I am not sure if these are used by an automatic documentation parser. I replaced them in favor of javadoc.

3) Made the beans vector typed This will ensure type safety at compile time so there are not any hidden/unexpected runtime errors. Generics are supported by everything including and after J2SE 5.0 which came out in 2004, so I think we will not have to worry about backwards compatibility in new releases

4) Flattened the code There was a lot of unnecessary nesting which made the code harder to read. I removed the try catch blocks outside of run() because none of the functions they are calling throw any errors

5) I added a handler for the InterruptionException thrown by Thread.sleep() This will allow for the thread to shutdown gracefully if asked by the runtime.