5 ms·
It seems though that if you're writing a book that is used as a documentation reference, you should be fitting with the coding standards that Apple uses for the
by seanalltogether 13y ago
It seems though that if you're writing a book that is used as a documentation reference, you should be fitting with the coding standards that Apple uses for their own documentation. You would be hard pressed to find any framework header or apple doc that doesn't use -(id)mymethod
- mpweiher 13y agoWhy? (Hint: the book demonstrates that quite a few things that Apple recommends are, how shall I say it, not entirely optimal)
- seanalltogether 13y agoBecause Apple is constantly evolving the language, and you could genuinely find that they change the compiler to deprecate this "feature" down the road.
- coldtea 13y agoOr they could enforce this feature. Generally writing a book about a language, you should not be occupied with what a FUTURE version of a language noone has announced MIGHT be.
- deleted 13y ago[deleted]
- bennyg 13y agoOr you could write idiomatic Objective-C and maybe save a chapter or section for being clever.
- kenferry 13y agoWell that was a tease. :-) Any examples?
- mpweiher 13y agoHi Ken! In the book? ;-)
- jasonlotito 13y ago> how shall I say it, not entirely optimal In what way? Is there a measurable performance penalty paid for including the return type of (id)? There is clearly a penalty paid in understanding and clarity, which flies in the face of the topic of your book. If you have explained that, than your reviewers aren't reading your book (which is a different problem of sorts). Considering your books is targeted at the Apple audience, I think these are fair questions. Simply saying "because I can" or "this is how I've always done it" isn't really good enough. However, if you can point to real benefits to not including the default type in the definition (something more subjective than clarity in your eyes), then you should spend time explaining that.
- mpweiher 13y agoThere is no execution side difference for writing or omitting the (id). The point is that you shouldn't follow advice blindly, even if it comes from Apple. The KISS principle or Occam's razor strongly suggest that those who introduce redundant entities are the ones who have to justify their choice, not the other way around. "Everybody does it this way, now" is a reason, though we can debate whether it is a good one.