{"id":21,"date":"2014-11-08T02:40:26","date_gmt":"2014-11-08T02:40:26","guid":{"rendered":"http:\/\/aristotle2digital.blogwyrm.com\/?p=21"},"modified":"2014-11-08T02:40:26","modified_gmt":"2014-11-08T02:40:26","slug":"essentials-accidentals-and-programming","status":"publish","type":"post","link":"https:\/\/aristotle2digital.blogwyrm.com\/?p=21","title":{"rendered":"Essentials, Accidentals, and Programming"},"content":{"rendered":"<p>In the last post, I spoke a little about essentials and accidentals, but I didn&#8217;t try to define these terms.\u00a0 In this post, I touch upon their traditional definitions in philosophy, and then turn to the application of these ideas to object-oriented programming.<\/p>\n<p>At the heart of the philosophical concepts of <a href=\"http:\/\/plato.stanford.edu\/entries\/essential-accidental\/\">essentials and accidentals<\/a> is the classification or categorization of the property of an object as being needed (essential) or as being possible (accidental).\u00a0 The use of the words \u2018must\u2019 and \u2018could\u2019 work nicely in this regard.\u00a0 Consider the following two sentences:<\/p>\n<p style=\"text-align: center;\">A mammal must have warm blood.<\/p>\n<p style=\"text-align: center;\">A mammal could have fur.<\/p>\n<p>The first captures an essential property of a mammal (namely that it regulates its internal temperature) while the second describes an accidental (it may have fur like a dog or have no fur like a dolphin).<\/p>\n<p>All this sounds simple enough in principle, but there are always problems in the application.\u00a0 The most common problem is that two people considering the same object won\u2019t necessarily list the same number or type of its properties or classify them in the same way essential or accidental.\u00a0 These differences reflect differences in perception, perspective, and the context and relative importance that each person places on the object.\u00a0 For example, a mechanic may view a car\u2019s essential properties as including weight, acceleration, torque, and engine displacement. \u00a0A city planner may view a car\u2019s essential properties to include how often it is driven, its average speed, and its fuel mileage.<\/p>\n<p>To illustrate this idea in more detail let\u2019s start by examining something as simple as an ideal geometric point in a two-dimensional plane, a favorite prop in Euclidean geometry. An essential property most people would agree upon would be that an ideal point actually takes up no space, that is to say that it is truly zero-dimensional.\u00a0\u00a0 Others may expand the list of essential properties to include the notion that the point must have a location within the plane.\u00a0 The list of accidental properties is much harder to nail down (precisely because they are not \u2018musts\u2019) but could include things like the color of the point as drawn or imagined, the distance of the point from an arbitrary origin, and the coordinate system and values within it for the position of the point.\u00a0 Thus this simple object from high school geometry is not as sweet and innocent as it seems.\u00a0 Scratch below the surface and it reveals a surprising degree of complexity and a tenacious resistance in being precisely defined.\u00a0 The situation grows more complex as we turn our attention to composite objects \u2013 objects that are made of parts that we could characterize as objects in their own right.<\/p>\n<p>The idea of assigning essential and accidental properties to an object becomes even more interesting when the object is not in the real world but is in cyberspace.\u00a0 In this context, we are not simply the natural philosopher trying to characterize the objects we find or create in our world in the hope of inferring something true about all objects of that type. As programmers, we become the first cause in the microcosm of our program, and our choices in understanding how and why we choose a particular definition reveal things both profound and interesting about ourselves as thinking beings.<\/p>\n<p>The creation or definition of an object, or more precisely an object class, is a way of mapping a mental conception of the <strong><em>mode of being of the object<\/em><\/strong> into computer instructions for handling <strong><em>data about those modes<\/em><\/strong>.\u00a0 Defining what these terms mean precisely is a difficult endeavor but let me start by at least posing some questions to consider in order to help in fleshing these ideas out.<\/p>\n<ul>\n<li>What do the philosophical terms \u2018essential\u2019 and \u2018accidental\u2019 mean when we are the creators of the form of an object (i.e., the class)?<\/li>\n<li>Do the object properties represent an essential or an accidental property of an object?<\/li>\n<li>Is it true that the value of member data is always an accidental?<\/li>\n<\/ul>\n<p>Again concrete illustrations will be much more useful.\u00a0 Consider an OOP representation of the ideal point, which is frequently presented in discussions about <a href=\"http:\/\/docs.oracle.com\/javase\/tutorial\/2d\/geometry\/primitives.html\">graphics primitives<\/a>.\u00a0 A typical construction might look like (in a language-agnostic form)<\/p>\n<p><a href=\"http:\/\/aristotle2digital.blogwyrm.com\/wp-content\/uploads\/2014\/11\/Essentials_Accidentals_and_Programming.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-23 aligncenter\" src=\"http:\/\/aristotle2digital.blogwyrm.com\/wp-content\/uploads\/2014\/11\/Essentials_Accidentals_and_Programming-300x143.jpg\" alt=\"Essentials_Accidentals_and_Programming\" width=\"300\" height=\"143\" srcset=\"https:\/\/aristotle2digital.blogwyrm.com\/wp-content\/uploads\/2014\/11\/Essentials_Accidentals_and_Programming-300x143.jpg 300w, https:\/\/aristotle2digital.blogwyrm.com\/wp-content\/uploads\/2014\/11\/Essentials_Accidentals_and_Programming.jpg 490w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Note that I am only dealing with the object\u2019s properties and not how they are assigned or observed, so all the machinery that allows the object to interact with the outside environment (<a href=\"http:\/\/stackoverflow.com\/questions\/1568091\/why-use-getters-and-setters\">\u2018getters\u2019 and \u2018setters\u2019<\/a>) will be suppressed.<\/p>\n<p>Now that we have defined our (computational) object let\u2019s see if we can classify which parts of our object definition are essential and which are accidental.\u00a0 A curious point is now apparent: there is no obvious place where we specify that the agreed-upon essential property of an ideal geometric point is that it is zero-dimensional.\u00a0 Clearly all objects that are instantiations of the class \u2018Point in a plane\u2019 possess this essential property but they don\u2019t know it and they can\u2019t share it with the rest of the world.<\/p>\n<p>It may seem that the only entity that knows this truth is the one who defined the object class in the first place.\u00a0 But a small amount reflection on how the programmer programs delivers a more likely explanation: that the creator doesn\u2019t really need to identify or even be aware of the essential properties of the object.\u00a0 The creator simply employs the very capacity he uses to learn and interact with the world when he defines the class.\u00a0 He doesn\u2019t know how he does it any more than a bird knows how it flies; he simply does. \u00a0The programmer then depends on this capacity to know how many and which kinds of objects get instantiated to perform whatever computational task is desired.<\/p>\n<p>What, then, to make of the object properties like \u2018x_component\u2019, \u2018y_component\u2019, and \u2018color\u2019?\u00a0 Are these essentials or accidentals?\u00a0 In some sense they are both.\u00a0 From the definition of the object class, these data are essential because they are required for all objects of type \u2018Point in a plane\u2019.\u00a0 But from the point-of-view of the programmer\u2019s mental conception of what the object represents they are usually accidentals since their actual values are clearly not important.\u00a0 Changing the color of a point or moving it around in the plane doesn\u2019t stop the object from being a point.\u00a0 So it is essential that the object has a memory location allocated to hold a value but it is completely accidental what value is inserted.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the last post, I spoke a little about essentials and accidentals, but I didn&#8217;t try to define these terms.\u00a0 In this post, I touch upon their traditional definitions in&#8230; <a class=\"read-more-button\" href=\"https:\/\/aristotle2digital.blogwyrm.com\/?p=21\">Read more &gt;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-21","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=21"}],"version-history":[{"count":0,"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts\/21\/revisions"}],"wp:attachment":[{"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}