Hacker News new | ask | show | jobs
by carson 5069 days ago
As much as I love seeing example apps like this I think beginners probably need to be cautious looking at this code. Here are a couple things that concern me:

* The UI is all hand coded. Not to start a religious war but interface builder makes supporting different devices a lot easier.

* There is some hairy concurrency stuff going on like this https://github.com/nothingmagical/cheddar-ios/blob/master/Cl...

4 comments

If you build lots of custom UI and animation, it's pretty hard to do it only with IB. E.g. with a custom component, you see a gray rect instead of how things are laid out, and you'd still need to write the custom bits in code anyway. Now you have the mess in 2 places.

There's also other reasons like version control, being able to copy-n-paste, using constants, etc.

Using IB without understanding how stuff is hand-coded is harder. In my workflows (solo iOS projects..) I have found manual interface creation to have less friction and less OMGWTFBBQ!?!? than trying to get everything working with IB.. not to mention that some properties aren't exposed in IB.
On UI: I cannot appreciate the opacity with which IB creates interfaces. I can't see at a glance what components and objects are related, bound, connected, etc.

That said, it's a fine tool to get you off the ground, but I'd rather see code and know how things are laid out than have to guess as I click inspectors, hover over connections, reference source files...

That "hairy" stuff is a straightforward use of GCD semaphores to signal when an animation has finished. I just spent 20 minutes reading up on GCD and dispatch_semaphore_wait(). This technique is elegant rather than hairy.
I just picked a line out of the area to point to. I'll pose a few questions that go into more about why I believe this is code that isn't straightforward and in general a bad reference point for a beginner:

* Can you tell me why that entire block of code gets dispatched to one queue then right into the main queue?

* Can you tell me what queue the animation completion blocks run on and why it might matter?

* Can you tell me what queue the network request runs on?

* Do you think the animation completes before the network request finishes? Can you tell me why/why not?

* What happens if the network request fails?