Android App
Trying out Coursera's Build Your First Android App (Project-Centered Course) by CentraleSupélec :D
Found this free certified course from this list of free certified coursera courses.
This app is part of Week 2's assignment.
Refactor
-
Magic number for miles per km:
0.621371
is moved to a Constant file. Improvement on Reusability and Readability. -
findViewId()
for inputs are moved outside the button click handlers. UI references for inputs only need to be assigned once, and this change avoids redundant reassignment each time button is clicked. Slight improvement on performance? -
Logic for conversion is moved to a
ConversionService
class, so that the conversion logic can be unit tested. Improvement on Testability.
Error Handling
- Toast reminder to enter valid input if input to be converted is invalid (eg. blank).
UI
- Restrict km and miles input type to decimal number.
android:inputType="numberDecimal"
Testing
- Added Unit Tests.