clear that if a new form condition holds, 2 things need to be done. • prepopulateForm( ) is back to doing 1 job. • It easy, lazy and dangerous to add new code inside a method that had a different purpose.
same name as the optional, or “same- name shadowing” per Erica Sadun. • the compiler has no issues, and it will only be local to the method. • The same goes for guard, use the optional’s name for the unwrapped type.
have a hierarchal design that you don’t anticipate changing very much. • If your types can be light-weight structs, use an enum with associated values. • Mix in some protocols to promise behavior. (protocol-based programming)
many NSLog and print statements. • You the developer need to find crashing conditions early not in QA • Go through every console log (NSLog, print) and replace with error reporting and/or add to them with an assertFailure
the unused result warning, and explicitly tells the reader “I am intentionally ignoring this returned value.” • Follow Xcode’s instructions or fix the code to make the warning go away • Sign of a broken-window-theory project are hundreds of warnings.
The heart of the problem is that segues and navigation are usually implemented in the view controllers. • This tightly couples 1 view controller to another. • Remove this responsibility with a Coordinator
view controller gets a coordinator • All vc coordinators are controlled by an AppCoordinator • Makes the ViewControllers do only what they’re supposed to, update the view. • Segues are negated, as the coordinators now control the navigation and app workflow
see it through out CocoaTouch. • Protocols let you swap out dependencies easily at run-time. • Coordinators can hold onto these protocol-based dependencies instead of ViewControllers. • Protocols enforce the you-have-1-job rule better.