{"id":11384,"date":"2015-06-01T11:10:43","date_gmt":"2015-06-01T15:10:43","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=11384"},"modified":"2015-06-02T10:14:55","modified_gmt":"2015-06-02T14:14:55","slug":"how-not-to-crash-7-dealing-with-nothing","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/06\/01\/how-not-to-crash-7-dealing-with-nothing\/","title":{"rendered":"How Not to Crash #7: Dealing With Nothing"},"content":{"rendered":"<p><a href=\"http:\/\/inessential.com\/2015\/05\/29\/how_not_to_crash_7_dealing_with_nothin\">Brent Simmons<\/a>:<\/p>\n<blockquote cite=\"http:\/\/inessential.com\/2015\/05\/29\/how_not_to_crash_7_dealing_with_nothin\">\n<p>With some OS X release (10.5, I think) Apple changed the format for crash logs on disk. I think they had been one file per app, and Apple switched to one file per crash. I had to write new code to handle the new format.<\/p>\n<p>I made the change. It went to beta testers, who used the app extensively. Weeks passed. All good.<\/p>\n<p>Then, on the day I released this version, I got a ton of reports from people who said, &ldquo;It&rsquo;s crashing on launch! But it works fine after launching it again.&rdquo;<\/p>\n<\/blockquote>\n<p>Update (2015-06-02): <a href=\"http:\/\/www.markbernstein.org\/Jun15\/HowNotToCrash7.html\">Mark Berstein<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.markbernstein.org\/Jun15\/HowNotToCrash7.html\"><p>If you do find yourself writing lots of <code>if(thing)...<\/code> tests, though, you might be better off passing a Null Object -- a subclass of the expected class that does nothing, and does it quickly.<\/p>\n<p>[&#8230;]<\/p>\n<p>So, instead of checking, Tinderbox initializes views with an instance of NoLayoutPolicy. If a view is being constructed and isn't quite ready to do real work, we can still call Prepare() in perfect safety. If we&rsquo;re about to disassemble a window, we can replace its layout policy with a fresh NoLayoutPolicy, confident that if someone tries to refresh the window we&rsquo;re demolishing, there will be a NoLayoutPolicy standing read to do nothing.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Brent Simmons: With some OS X release (10.5, I think) Apple changed the format for crash logs on disk. I think they had been one file per app, and Apple switched to one file per crash. I had to write new code to handle the new format. I made the change. It went to beta [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[69,31,30,32,392,54,71],"class_list":["post-11384","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-ios","tag-mac","tag-macapp","tag-netnewswire","tag-objective-c","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=11384"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11384\/revisions"}],"predecessor-version":[{"id":11392,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11384\/revisions\/11392"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=11384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=11384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=11384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}