Refactoring WebUI Views, PluginInfo and various Util classes. #14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By Martin Rogalla(4173635) and Peter Evers(4013964).
PluginInfo
By creating our test suite we found that the values of the
String
ConfigurationType
are not type checked, this could potentially lead toproblems when a null value is put into the database.
In the refactoring phase, the
fromString
function for the enumConfigurationType
was simplified. Java already has a function calledvalueOf
for enums, which basically performs the exact same task as thefromString
function. The only main difference was that it would returna null value, but this value was always checked in all the callees and
an exception would be thrown if it was null.
Thus the possibility for the return type to be null was removed and the
fromString
function was made responsible to throw the exception. Thisreduced code duplication in the file, giving a better overview.
ProjectVersion
The class was tested and a few minor bugs were fixed.
PAServiceImpl
The error-handling in
PAServiceImpl
was cluttered, as it relied mainlyon Boolean evaluations. This form of error-handling was replaced by the
usage of exceptions. Not only does this give a better overview, but it
also provides the logger with more detailed error messages. Some other
refactorings such a method extraction were performed as well. The logic
of this class remained the same, there was only extraction of methods,
which does not have a direct effect on the code functionality, but
improves code readability. Compatibility with the rest of the components
in the system remains, as the install function will still return a
boolean depending on its success or failure.
FileUtils/DiskUtils
These two utility classes were re-implementing methods for which
existing frameworks can be used. This violates the Single
Responsibility Principle, not on a class level, but rather on a
component level. Implementing these types of methods yourself increases
the likelihood of bugs, and clutters the project overview. Thus we
refactored all the classes which made use of this, to use the Apache
Commons IO library, specifically the
org.apache.commons.io.FileUtils
and
org.apache.commons.io.FilenameUtils
classes were replacements forFileUtils
andDiskUtils
. In order to fully test these changes itwould require a lot of time and which would inefficient if the affected
classes were not going to be refactored. Thus for these changes to be
made, we carefully analyzed the call hierarchy within the whole project,
and made the corresponding changes while checking the logic manually. In
total this allowed the removal of ~447 lines of code from the Alitheia
Core codebase.
PluginsView/ProjectsView
We have managed to reproduce the same functionality as the original
PluginView with only 10% of the original lines of code. The Open Closed
Principle is fixed, we can easily extend the template or write another
template for example if we want different designs.
Signed-off-by: Martin Jorn Rogalla [email protected]
Signed-off-by: Peter Evers [email protected]