Knowing when to read the manual
My usual fallback chain for solving a problem is Google, TDD and then RTFM. Sometimes it should just be to jump to step three.
The problem was trying to create what I now understand to be called a modal view that temporarily fills the iPhone’s screen and then is dismissed without disrupting work flow. I was using a navigation controller to manage the subviews and therefore the usual process is to add a new view to the controller’s stack. The user may then return to the previous screen with the back button.
Usually when coding web/iphone applications you’ll hit a problem that isn’t immediately solvable. The normal (fastest) solution is to hit Stackoverflow and modify a solution presented by another. These are usually small snippets of code that are either copyrighted under the Creative Commons License or held by the third party posting the code.
The navigation stack method is great in theory but I have to add code to remove the top navigation bar and the tab-bar at the bottom pragmatically. This could have proved annoying as you then have to replace them after the user pops back to the previous screen. You end up feeling like you working against the system.
In this case I tried 5 different attempts at the Google, copy, paste, hack process before I took a step back and decided my approach had to change. I usually fall back on the TDD process as I’ve already hooked up the GHUnit and OCMock libraries and just need to think of the smallest slice of the solution that is testable to move forward.
The problem this time is that I can’t think of the smallest slice that would constitute a test. I know what I want to do but It’s the fact that I don’t know what the real problem is or what to call it so I end up following a number of false starts. This is when I reverted to the original fallback I used to use and some might suggest would have been the best place to start: RTFM.
This approach enlightened; I want a modal view: “Modal view controllers are a tool that you have for interrupting the current workflow and displaying a new set of views.” This is ideal and development from this point was easy.
The moral for this story is to use your intuition as to when just reading the manual is the right direction to go. It might seem like it will take longer when under pressure but if you’ve failed to implement the hack solution 5 or more times then you need take a step back.