{"id":8466,"date":"2014-02-21T17:35:06","date_gmt":"2014-02-21T22:35:06","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=8466"},"modified":"2014-02-21T17:35:06","modified_gmt":"2014-02-21T22:35:06","slug":"kvo-considered-harmful","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2014\/02\/21\/kvo-considered-harmful\/","title":{"rendered":"KVO Considered Harmful"},"content":{"rendered":"<p><a href=\"http:\/\/khanlou.com\/2013\/12\/kvo-considered-harmful\/\">Soroush Khanlou<\/a> (via <a href=\"https:\/\/twitter.com\/mpweiher\/status\/409991467508432896\">Marcel Weiher<\/a>):<\/p>\n<blockquote cite=\"http:\/\/khanlou.com\/2013\/12\/kvo-considered-harmful\/\"><p>All of these nuances in the API cause KVO to embody what is known as a <em>pit of failure<\/em> rather than a pit of success. The pit of success is a concept that <a href=\"http:\/\/www.codinghorror.com\/blog\/2007\/08\/falling-into-the-pit-of-success.html\">Jeff Atwood<\/a> talks about. APIs should be designed so that they guide you into using them successfully. The should give you hints as to how to use them, even if they don&rsquo;t explain <em>why<\/em> you should use them in that particular way.<\/p>\n<p>KVO does none of those things. If you don&rsquo;t understand the subtleties in the parameters, or if you forget any of the details in implementation (which I did, and only noticed because I went back to my code to reference it while writing this blogpost), you can cause horrible unintended behaviors, such as infinite loops, crashes, and ignored KVO notifications.<\/p><\/blockquote>\n<p>I wish Cocoa didn&rsquo;t have APIs that require you to use KVO.<\/p>","protected":false},"excerpt":{"rendered":"<p>Soroush Khanlou (via Marcel Weiher): All of these nuances in the API cause KVO to embody what is known as a pit of failure rather than a pit of success. The pit of success is a concept that Jeff Atwood talks about. APIs should be designed so that they guide you into using them successfully. [&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,275,54,71],"class_list":["post-8466","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-keyvalueobserving","tag-objective-c","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8466","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=8466"}],"version-history":[{"count":0,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8466\/revisions"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=8466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=8466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=8466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}