{"id":1393,"date":"2012-11-15T07:22:00","date_gmt":"2012-11-15T12:22:00","guid":{"rendered":"http:\/\/irreal.org\/blog\/?p=1393"},"modified":"2012-11-15T07:23:41","modified_gmt":"2012-11-15T12:23:41","slug":"some-common-sense-on-oop","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=1393","title":{"rendered":"Some Common Sense on OOP"},"content":{"rendered":"<p>A few days ago, I ran across an interesting and commonsensical <a href=\"http:\/\/prog21.dadgum.com\/156.html\">article on OOP<\/a> by James Hague over at <a href=\"http:\/\/prog21.dadgum.com\/\">programming in the twenty-first century<\/a>. In it he says that while OOP is sometimes useful, it&#8217;s not a fundamental particle of computing. Too often, he says, OOP is blindly applied to inappropriate problems. Problems that aren&#8217;t complicated enough to warrant its use and the difficulties that it brings.<\/p>\n<p>It is, as I say, an interesting post and I was going to blog about it in a little more detail but Rob Pike beat me to it with his own <a href=\"https:\/\/plus.google.com\/101960720994009339267\/posts\/hoJdanihKwb\">post on OOP<\/a> that makes the same point\u2014and even mentions Hague&#8217;s post\u2014in a more provocative way. Pike points to an example of OOP run amok that can be characterized only as terrifying. Pike says of it<\/p>\n<blockquote><p>Local discussion focused on figuring out whether this was a joke or<br \/>\nnot. For a while, we felt it had to be even though we knew it wasn&#8217;t.<\/p><\/blockquote>\n<p>I can&#8217;t begin to describe the horror of it so you&#8217;ll have to go over to Pike&#8217;s post and follow the link that he gives.<\/p>\n<p>The problem itself is to determine the operating system you&#8217;re running on and output a value judgment about it. As Pike says, this is a trivial problem that can be solved easily with a simple table look up in any language. Here it is in Elisp, for example:<\/p>\n<pre class=\"src src-emacs-lisp\">(<span style=\"color: #a020f0;\">defvar<\/span> <span style=\"color: #a0522d;\">systems<\/span> '((usg-unix-v <span style=\"color: #8b2252;\">\"UNIX\"<\/span> <span style=\"color: #8b2252;\">\"good\"<\/span>)\r\n                  (gnu\/linux <span style=\"color: #8b2252;\">\"UNIX\"<\/span> <span style=\"color: #8b2252;\">\"good\"<\/span>)\r\n                  (windows-nt <span style=\"color: #8b2252;\">\"Windows\"<\/span> <span style=\"color: #8b2252;\">\"bad\"<\/span>)\r\n                  (darwin <span style=\"color: #8b2252;\">\"Mac OS\"<\/span> <span style=\"color: #8b2252;\">\"far superior\"<\/span>)))\r\n\r\n(<span style=\"color: #a020f0;\">let<\/span> ((box (assoc system-type systems)))\r\n  (<span style=\"color: #a020f0;\">if<\/span> box\r\n      (message <span style=\"color: #8b2252;\">\"This is a %s box and therefore %s.\"<\/span> (cadr box) (caddr box))\r\n    (message <span style=\"color: #8b2252;\">\"This is not a box.\"<\/span>)))<\/pre>\n<p>Simple, extensible, and not a class to be seen.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few days ago, I ran across an interesting and commonsensical article on OOP by James Hague over at programming in the twenty-first century. In it he says that while OOP is sometimes useful, it&#8217;s not a fundamental particle of &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=1393\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[18],"class_list":["post-1393","post","type-post","status-publish","format-standard","hentry","category-programming","tag-emacs"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1393"}],"version-history":[{"count":3,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1393\/revisions"}],"predecessor-version":[{"id":1396,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1393\/revisions\/1396"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}