{"id":6783,"date":"2013-01-07T14:11:36","date_gmt":"2013-01-07T19:11:36","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=6783"},"modified":"2013-01-07T14:11:37","modified_gmt":"2013-01-07T19:11:37","slug":"dependency-injection-is-a-virtue","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2013\/01\/07\/dependency-injection-is-a-virtue\/","title":{"rendered":"Dependency Injection Is a Virtue"},"content":{"rendered":"<p><a href=\"http:\/\/blog.metaobject.com\/2013\/01\/dependency-injection-is-virtue.html\">Marcel Weiher<\/a> rebuts <a href=\"http:\/\/david.heinemeierhansson.com\/2012\/dependency-injection-is-not-a-virtue.html\">David Heinemeier Hansson<\/a>:<\/p>\n<blockquote cite=\"http:\/\/blog.metaobject.com\/2013\/01\/dependency-injection-is-virtue.html\"><p>Having hard-coded class-names like in the example <code>Time.now<\/code> is effectively the same as communicating\nvia global variables.  DHH&rsquo;s suggestion of stubbing out the Time class&rsquo;s <code>now<\/code> is selling us mutable\nglobal variables as the solution to global variables.  Or more precisely:  passing an argument to a method\nby modifying a global variable that the method reads out and restoring the state of the global variable afterward.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Marcel Weiher rebuts David Heinemeier Hansson: Having hard-coded class-names like in the example Time.now is effectively the same as communicating via global variables. DHH&rsquo;s suggestion of stubbing out the Time class&rsquo;s now is selling us mutable global variables as the solution to global variables. Or more precisely: passing an argument to a method by modifying [&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":[71,268],"class_list":["post-6783","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-programming","tag-testing"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/6783","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=6783"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/6783\/revisions"}],"predecessor-version":[{"id":6784,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/6783\/revisions\/6784"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=6783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=6783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=6783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}