I originally built the iOS version of this view controller on a rather tight deadline, so it ended up suffering from a bad case of 'Massive View Controller Syndrome'. This ultimately meant it started getting messy when I started trying to extend it for requirements from certain clients.
To nip the already accumulating technical dept in the bud, I spent a bit of time refactoring the view controller and breaking out the code into appropriate models.
All of the view creation and layout code was moved to a UIView subclass that was then set directly as the view controller's view.
All of the logic managing the table view was broken out into its own LoginTableDataSource class.
All of the code involving the onscreen keyboard measurements and NSNotification handling was offloaded to its own class.
The form validation logic was wrapped in a barebones, given a protocol and exposed as a property. This will allow any third parties who mandate special input validation (eg, special password requirements) to be able to insert their own logic into the class this way.
The form submission method has been broken out in order to prepare for #27 to be integrated more cleanly.
I refactored how serverURL is parsed to be a lot safer. The view controller can be set as explicitly always requiring HTTPS, but can also optionally support it if the user manually enters a scheme into the field. It also has provisions for both secure and non-secure port numbers, and can implicitly swap between them if the user specifies a security level, but not a port number.
I didn't change a lot of this code, but at the same time, I'm not sure if everything still works. Now that code is much more modularized, I'm going to write some unit tests for the more complex logic. I'm going to hold off from merging this until then.
Until then, all comments and criticism welcome. :D
I originally built the iOS version of this view controller on a rather tight deadline, so it ended up suffering from a bad case of 'Massive View Controller Syndrome'. This ultimately meant it started getting messy when I started trying to extend it for requirements from certain clients.
To nip the already accumulating technical dept in the bud, I spent a bit of time refactoring the view controller and breaking out the code into appropriate models.
UIView
subclass that was then set directly as the view controller's view.LoginTableDataSource
class.NSNotification
handling was offloaded to its own class.serverURL
is parsed to be a lot safer. The view controller can be set as explicitly always requiringHTTPS
, but can also optionally support it if the user manually enters a scheme into the field. It also has provisions for both secure and non-secure port numbers, and can implicitly swap between them if the user specifies a security level, but not a port number.I didn't change a lot of this code, but at the same time, I'm not sure if everything still works. Now that code is much more modularized, I'm going to write some unit tests for the more complex logic. I'm going to hold off from merging this until then.
Until then, all comments and criticism welcome. :D