<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Psychology of Programming &#187; Understanding Code</title>
	<atom:link href="http://p.einarsen.no/category/understanding-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://p.einarsen.no</link>
	<description></description>
	<lastBuildDate>Thu, 24 Jun 2010 01:19:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Does code base structure follow organization structure?</title>
		<link>http://p.einarsen.no/does-code-base-structure-follow-organization-structure/</link>
		<comments>http://p.einarsen.no/does-code-base-structure-follow-organization-structure/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 08:19:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Management]]></category>
		<category><![CDATA[Understanding Code]]></category>
		<category><![CDATA[Writing Code]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[organizations]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[structure]]></category>

		<guid isPermaLink="false">http://p.einarsen.no/does-code-base-structure-follow-organization-structure/</guid>
		<description><![CDATA[After writing about the Software Engineering Myths Microsoft claims to have busted, I&#8217;ve been thinking about their find that organization structure is the most predictive factor for bugs.
And it makes me think, to what degree are organizations&#8217; code bases shaped by their formal or informal organization structure? Are core modules and root objects often the [...]]]></description>
			<content:encoded><![CDATA[<p>After writing about the <a href="http://p.einarsen.no/debunking-software-engineering-myths-does-the-organization-matter-more-than-the-programming/" target="_blank">Software Engineering Myths Microsoft claims to have busted</a>, I&#8217;ve been thinking about their find that organization structure is the most predictive factor for bugs.</p>
<p>And it makes me think, to what degree are organizations&#8217; code bases shaped by their formal or informal organization structure? Are core modules and root objects often the domain of senior developers and objects lower in the hierarchy the domain of juniors? My experience is that it often tends to be, and it seems a reasonable overlap: after all, you want your more trusted developers fiddling where the damage can be greatest.</p>
<p>But how about other attributes of the code base? In the world of Perl, are CPAN authors often hired as external consultants? Are the most communicative programmers the ones that will write network services? Are the modules most used also written by the programmers that are most in contact with others?</p>
<p>And does organization structure also shape general code base structure? Will a more hierarchical organization tend more towards hierarchical object structures, while more chaotic or flat organizations tend towards more chaotic or flat code organization?</p>
<p>A lot of questions, but no answers&#8230; But one thing that comes to mind is, if organization and code structure follows each other, is this a good idea? I think few people designing a data model or object hierarchy starts with the organization structure as a blueprint, but speaking from my own limited experience, you can often at least see a reflection of either in both.  Is this a good or bad thing? What can the consequences be?</p>
]]></content:encoded>
			<wfw:commentRss>http://p.einarsen.no/does-code-base-structure-follow-organization-structure/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Why do programmer personality types matter?</title>
		<link>http://p.einarsen.no/programmer-personality-types-and-why-it-matters-at-all/</link>
		<comments>http://p.einarsen.no/programmer-personality-types-and-why-it-matters-at-all/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 21:13:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Metrics]]></category>
		<category><![CDATA[Understanding Code]]></category>
		<category><![CDATA[Writing Code]]></category>
		<category><![CDATA[API's]]></category>
		<category><![CDATA[Cognition]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Personality]]></category>
		<category><![CDATA[Style]]></category>

		<guid isPermaLink="false">http://p.einarsen.no/?p=238</guid>
		<description><![CDATA[How do programmers differ, and why should you care? Steven Clarke from Microsoft&#8217;s usability labs has identified and demonstrated at least three different programmer styles, which has been reported in quite a few places, hence programmers do indeed differ. The types Clarke found are:
THE SYSTEMATIC DEVELOPER: Writes code defensively. Does everything he or she can [...]]]></description>
			<content:encoded><![CDATA[<p>How do programmers differ, <em>and why should you care</em>? <a href="http://blogs.msdn.com/stevencl/" target="_blank">Steven Clarke</a> from Microsoft&#8217;s usability labs has identified and demonstrated at least three different programmer styles, which has been reported in quite <a href="http://www.mertner.com/morten/?p=11" target="_blank">a</a> <a href="http://asserttrue.blogspot.com/" target="_blank">few</a> <a href="http://blogs.msdn.com/brada/archive/2003/11/18/50737.aspx" target="_blank">places</a>, hence programmers do indeed differ. The types Clarke found are:</p>
<blockquote><p><strong>THE SYSTEMATIC DEVELOPER: </strong>Writes code defensively. Does everything he or she can to protect code from unstable and untrustworthy processes running in parallel with their code. Develops a deep understanding of a technology before using it. Prides himself or herself on building elegant solutions.<br />
<strong>THE PRAGMATIC DEVELOPER:</strong> Writes code methodically. Develops sufficient understanding of a technology to enable competent use of it. Prides himself or herself on building robust applications.<br />
<strong>THE OPPORTUNISTIC DEVELOPER: </strong>Writes code in an exploratory fashion. Develops a sufficient understanding of a technology to understand how it can solve a business problem. Prides himself/herself on solving business problems.</p></blockquote>
<p><em>Now why should you care?</em></p>
<p>Almost every mention I&#8217;ve seen of this online &#8211; or of any other personality type categorization system &#8211; is usually followed by a &#8220;<em>which type are you</em>?&#8221;. This misses the point utterly and completely. Psychological research like this first becomes really valueable when you <strong>stop thinking about yourself </strong>and start asking how this can help you <strong>understand</strong> <strong>other people</strong>. If you design API&#8217;s and base your design on what makes most sense to your own coding style, you will create something that two thirds of your audience will find difficult to use. Even if you don&#8217;t like or agree with their style.</p>
<p>Granted, that makes the assumption that programmers are always equally distributed among styles, which is a pretty wild assumption. The point is that other people are more likely to think differently than similarly to you.</p>
<p>That is also a good thing to keep in mind when formatting code for readability: if your coding style differs from standard <a href="http://perltidy.sourceforge.net/" target="_blank">Perl Tidy</a> or your company&#8217;s coding standard, keep in mind that you are not formatting for yourself, but a colleague, maintainer or anonymous CPAN downloader. They are more likely to understand a common standard than your standard.  It sounds obvious, don&#8217;t it? I don&#8217;t think many (any) programmers think like this even so.</p>
<p><img class="alignright" title="Figure 1" src="http://p.einarsen.no/wp-content/upload/clarke.fig1.png" alt="" width="232" height="237" />Now, <a href="http://brad_abrams.members.winisp.net/Projects/APIDesignPapers/MeasuringAPIUsability.pdf" target="_blank">Clarke, in an article to Dr. Dobbs Journal</a>, has an example of a cognitive mapping of programmer types and API traits which is quite illustrative.  In Figure 1, thick blue lines shows the expectations of a particular programmer type, while the dark lines shows the score of a particular API. As you can see in this case, the match is bad. Now the good thing is that Clarke&#8217;s research gives you a framework to discuss how and why.</p>
<p><a href="http://brad_abrams.members.winisp.net/Projects/APIDesignPapers/Dagstuhl.pdf" target="_blank">That&#8217;s important because programming style isn&#8217;t related to experience level or educational background.</a> An programmer with an opportunistic style will not necessarily grow into a systematic programmer with more experience, neither will a systematic programmer become more pragmatic with age. Or perhaps they will &#8211; but you can&#8217;t assume that.</p>
<p>Finally, the dimensions which Clarke suggests APIs can be understood on at a cognitive level:</p>
<blockquote><p>• <strong>Abstraction level. </strong>The minimum and maximum levels of abstraction exposed by the API, and the minimum and maximum levels usable by a targeted developer.</p>
<p>• <strong>Learning style.</strong> The learning requirements posed by the API, and the learning styles available to a targeted developer.</p>
<p>• <strong>Working framework.</strong> The size of the conceptual chunk (developer working set) needed to work effectively.</p>
<p>• <strong>Work-step unit. </strong>How much of a programming task must/can be completed in a single step.</p>
<p>• <strong>Progressive evaluation.</strong> To what extent partially completed code can be executed to obtain feedback on code behavior.</p>
<p>• <strong>Premature commitment</strong>. The amount of decisions that developers have to make when writing code for a given scenario and the consequences of those decisions.</p>
<p>• <strong>Penetrability</strong>. How the API facilitates exploration, analysis, and understanding of its components, and how targeted de- velopers go about retrieving what is needed.</p>
<p>• <strong>API elaboration.</strong> The extent to which the API must be adapted to meet the needs of targeted developers.</p>
<p>• <strong>API viscosity.</strong> The barriers to change inherent in the API, and how much effort a targeted developer needs to expend to make a change.</p>
<p>• <strong>Consistency.</strong> How much of the rest of an API can be inferred once part of it is learned.</p>
<p>• <strong>Role expressiveness.</strong> How apparent the relationship is between each component exposed by an API and the program as a whole.</p>
<p>• <strong>Domain correspondence.</strong> How clearly the API components map to the domain and any special tricks that the developer needs to be aware of to accomplish some functionality.</p></blockquote>
<p>Steven Clarke seems to have discontinued his blog, but his scientific work is <a href="http://en.scientificcommons.org/steven_clarke" target="_blank">chronicled at Scentific Commons</a>.</p>
<p>(Found, among other places, <a href="http://asserttrue.blogspot.com/" target="_blank">assertTrue()</a> ).</p>
]]></content:encoded>
			<wfw:commentRss>http://p.einarsen.no/programmer-personality-types-and-why-it-matters-at-all/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cognition, computers and electric currents</title>
		<link>http://p.einarsen.no/cogntition-computers-and-electric-currents/</link>
		<comments>http://p.einarsen.no/cogntition-computers-and-electric-currents/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 12:31:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Language]]></category>
		<category><![CDATA[Understanding Code]]></category>
		<category><![CDATA[Writing Code]]></category>
		<category><![CDATA[action potentials]]></category>
		<category><![CDATA[cogntion]]></category>
		<category><![CDATA[physiology]]></category>

		<guid isPermaLink="false">http://p.einarsen.no/?p=207</guid>
		<description><![CDATA[This is just a quick quote from the course description of a ten year old course in Cognitive Psychology and Computer Programming at the Texas A&#38;M:
Computer programming perhaps more than any other manufacturing endeavor begins with a thought and through skilled application of knowledge yields an intrinsically proven object that is itself almost mental (encoded [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a quick quote from the course description of a ten year old <a href="http://www.rtis.com/nat/user/jfullerton/school/psyc345/program.htm" target="_blank">course in Cognitive Psychology and Computer Programming</a> at the Texas A&amp;M:</p>
<blockquote><p>Computer programming perhaps more than any other manufacturing endeavor begins with a thought and through skilled application of knowledge yields an intrinsically proven object that is itself almost mental (encoded electrical information).</p></blockquote>
<p>It&#8217;s a good argument for why cognitive psychology is relevant for computer programming, but even more important, it points out the almost mental nature of computer programs.</p>
<p>Physiologically, the way our brains operate is mainly through bursts of electrical current called <a href="http://en.wikipedia.org/wiki/Action_potential" target="_blank">Action Potentials</a>, that propagate information down neurons in a on-off fashion. Some people will call it binary, but the information conveyed is typically frequencies rather than binary patterns  (But this is a somewhat contentious question).</p>
<p>Here&#8217;s a beautiful drawing of neural communication from Wikipedia:</p>
<p><a href="http://en.wikipedia.org/wiki/Action_potential" target="_blank"><img class="alignnone" title="Neuron" src="http://upload.wikimedia.org/wikipedia/commons/3/3e/Neurons_big1.jpg" alt="" width="510" height="539" /></a></p>
<p>So you have a mental construction in a human brain contained in electrical signals, and this is transferred over to a construction of electrical signals in a computer.  Add that you usually want these two representations to be identical, you have a good argument why programming language design should be based strongly on cognitive science!</p>
]]></content:encoded>
			<wfw:commentRss>http://p.einarsen.no/cogntition-computers-and-electric-currents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is readability, or simple != readable</title>
		<link>http://p.einarsen.no/what-is-readability-or-simple-readable/</link>
		<comments>http://p.einarsen.no/what-is-readability-or-simple-readable/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 20:07:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Language]]></category>
		<category><![CDATA[Understanding Code]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[readability]]></category>
		<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://p.einarsen.no/?p=161</guid>
		<description><![CDATA[As a programmer, you write for two very different kinds of readers. One is the rigid computer platform, the other is the human maintainers of your code. For the former we have quite conclusive guidelines on what works, but the latter is only consistent as a source of disagreement and uncertainty. Typically the guideline is [...]]]></description>
			<content:encoded><![CDATA[<p>As a programmer, you write for two very different kinds of readers. One is the rigid computer platform, the other is the human maintainers of your code. For the former we have quite conclusive guidelines on what works, but the latter is only consistent as a source of disagreement and uncertainty. Typically the guideline is &#8220;<em><a href="http://c2.com/cgi/wiki?CodeForTheMaintainer">Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.</a></em>&#8220;, while most people end up writing as if the person maintaining the code is themselves.</p>
<p>Neither approach is particularly good -I can&#8217;t imagine code written for violent psychopaths  would really be that great to maintain. And on the other end, a lot of coders optimize for their own readability, and will argue the finer points of formatting from that point of view, not that of <em>the actual readers</em> &#8211; missing the point that readability is ultimately decided by the reader, not the writer.</p>
<p>I certainly catch myself doing this quite often.</p>
<p>In the Perl world, this is probably an even bigger issue than in other languages.  <a href="http://en.wikipedia.org/wiki/There%27s_more_than_one_way_to_do_it">There-Is-More-Than-One-Way-To-Do-It</a> is still one of Perls big strenghts, but certainly not all the ways are equally good &#8211; which is why <a href="http://oreilly.com/catalog/9780596001735/">Perl Best Practices</a> is now a staple of any Perl-wielding office. The contrasting Python, with it&#8217;s <a href="http://www.python.org/dev/peps/pep-0020/">&#8220;there should be one — and preferably only one — obvious way to do it&#8221;</a>, seems to be able to get away with 19 simple statements to define the pythonic best practice.</p>
<p>Now, anyone can have an opinion, particularly since research on code readability it still quite lacking. We just don&#8217;t know for certain yet what makes people get code. However, cognitive psychologists have been interested for several decades in how people generally organize large data structures in their brains, and some of this has given some neat practical applications for coding, such as <a href="http://www.si.umich.edu/furnas/Papers/FisheyeCHI86.pdf">Furnas&#8217; paper on &#8216;Fish-eye&#8217; views (1986)</a>. (This is basically about IDEs with collapsing code branches, but now you know why that&#8217;s nice, how to do it right and who thought of it first.)</p>
<p>Research on general language comprehension, however, is a massive field. In the <a href="http://www.acm.org/jcdl/jcdl01/">ACM Journal of Computer Documentation</a>&#8217;s August 2000 issue, <a href="http://portal.acm.org/citation.cfm?id=344599.344630">George R. Klare provides some clear-minded and research-based adviced for communicators </a>that might be enlightening and is a good starting point for thinking about readability of normal text &#8211; that might apply to programming.</p>
<p>He specifies four purposes of readability:</p>
<ul>
<li>Reading speed and efficiency.</li>
<li>Reader judgment.</li>
<li>Readership.</li>
<li>Comprehension, Learning and Retention.</li>
</ul>
<p>Of these, only the last is of any big interest for programmers; you don&#8217;t typically care about the speed the maintainer needs to read your code. You might care about the Reader  judgment if you code to impress your fellow programmers, but that is another chapter. Readership applies to how the size of the readership may be a function of  the simplicity of the text &#8211; a consideration on the skill level of your maintainers, perhaps, but few people code with the intention of their code to be read by a large audience.</p>
<p>However, the biggest issue with text and code is comprehension. Even more so in programming code, as it is essential that the maintainer is able to create a <em>precise</em> representation of the code in his own mind. Also he must be able to understand both what it actually does and what the intention is, since these don&#8217;t always add up.  For debugging purposes, it is actually completely essential that the reader can separate the soft human intentions from the hard computer operations, so any code must be understood on two levels simultaneously.</p>
<p>Now, how does readability affect comprehension? First, keep in mind that readability in natural language usually refers to choice of words and sentence length, and is typically measured by level of education necessary to read the text. This might not be appropriate for code readability &#8211; level of programming skill might not map to level of code understanding in the same way, and readability in code is often just a matter of indentation and syntactics.</p>
<p>But it probably maps somewhat close. This is where research is lacking again, so it is hard to tell.</p>
<p>Klare&#8217;s big advice, however, is that higher readability does not always convert into higher comprehension, but is modulated by situation and traits in the readers. And that is the important part. He describes four conditions when it does not work as you would think:</p>
<ol>
<li>A reader can understand at higher levels than expected if his motivation is high. Also, skill level is a fuzzy concept.</li>
<li>If time is not limited, increase in readability might not make a difference on comprehension. The more time is limited, the larger the effect of readability</li>
<li>The greater the readers background knowledge on the topic, the less effect does readability have. On the other hand, even an expert on one field may prefer higher levels of readability in texts outside his field.</li>
<li>Type and level of motivation might affect comprehension.</li>
</ol>
<p>or to quote his summary:</p>
<blockquote><p>[..] more readable, written material is likely to produce greater comprehension, learning and retention than less readable only when one or more of the following factors are present: the less readable is much harder than the more readable, and clearly beyond the reader&#8217;s usual level; reading time is limited; the reader does not have a large amount of background or experience with the topic being covered; and, the reader has a relatively strong set to learn.</p></blockquote>
<p>Now does this particulary increase understanding of readability of programming code?</p>
<p>Perhaps not.</p>
<p>However, if we think of readability not as just the reading of code as natural language, but rather of understanding of the semantic concepts, there is an interesting observation to be made.  If we consider using more basic programming to make the program easier to understand, while avoiding more advanced concepts, Klare&#8217;s summary of readability shows something that also adds up with other research, namely that <em>this approach to readability doesn&#8217;t always increase comprehension.</em></p>
<p>In a very recent piece of research using Scala, <a href="http://infoscience.epfl.ch/record/138586?of=HD">Gilles Dubouchet found that using more compact and advanced functional programming methods rather than basic, typical loop-constructs increased comprehension</a>.  Although one single piece of research such as Dubouchet&#8217;s is too limited to base decisions on, it becomes more interesting when it actually adds up with prior research on language comprehension.</p>
<p><strong>Together it indicates that using more advanced methodology can increase comprehension for both original programmers and maintainers, unless they are pressed on time or motivation.</strong></p>
<p>Unlike many other languages, Perl allows you to increase the complexity of your programming across methodology quite freely. You can start with the simple baby-Perl, go through procedural programming, add objects or start playing with functional approaches. You can use <a href="http://search.cpan.org/~adamk/Aspect-0.21/lib/Aspect.pm">Aspect Oriented Programming</a> or add on your own crazy, homespun programming methodology, if you so please.  For <em>comprehension and readability purposes</em>, the above research indicates that if you consider your audience and their situation well, going for a higher and more advanced level might not be a disadvantage.</p>
<p>But do keep in mind that the research is still a bit patchy, and this is mostly an argument without empirical data. But I&#8217;ll make sure I report what I find, as this is just the first in many articles about readability&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://p.einarsen.no/what-is-readability-or-simple-readable/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Objects and your brain: Why do we love object-oriented programming so?</title>
		<link>http://p.einarsen.no/objects-and-your-brain-why-do-we-love-object-oriented-programming-so/</link>
		<comments>http://p.einarsen.no/objects-and-your-brain-why-do-we-love-object-oriented-programming-so/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 21:02:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Understanding Code]]></category>
		<category><![CDATA[categorization]]></category>
		<category><![CDATA[cogntive psychology]]></category>
		<category><![CDATA[HCI]]></category>
		<category><![CDATA[objects]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://p.einarsen.no/?p=140</guid>
		<description><![CDATA[15 years ago, the research journal Human-Computer Interaction published their special issue on Object-Oriented Programming.  Having realized that a lot of the claims made about OOP at the time were not technical in nature, but rather were psychological and cognitive, the special issue attempted to present empirical and experimental research examining the claims about OOPs [...]]]></description>
			<content:encoded><![CDATA[<p>15 years ago, the research journal <a href="http://hci-journal.com/">Human-Computer Interaction</a> published their <a href="http://www.informaworld.com/smpp/608427397-73843868/title~db=all~content=g784766161">special issue on Object-Oriented Programming</a>.  Having realized that a lot of the claims made about OOP at the time were not technical in nature, but rather were psychological and cognitive, the special issue attempted to present empirical and experimental research examining the claims about OOPs advantages on procedural programming. Or as the editor <a href="http://www.informaworld.com/smpp/ftinterface~db=all~content=a784766112~fulltext=713240930">Bill Curtis notes</a>:</p>
<blockquote><p>Object-oriented (OO) design and programming trace their lineage to research on abstract data types in the late 1960s and early 1970s, but they did not become popular software development techniques until the late 1980s. In all this time there has been little serious empirical or experimental study of OO techniques. What usually passes for evaluation is either a testimonial from an industry pundit who may have developed a small application using an OO technique [..]</p></blockquote>
<p>and..</p>
<blockquote><p>Even worse, this special issue of Human-Computer Interaction will be read by very few of the thousands of the people who read Computerworld, Information Week, Datamation, Software Development, and the other trade press periodicals in which OO methods are touted as often as explained. The results reported in this special issue are promising, <em>but simultaneously they provide sobering expectations about the effort involved in obtaining the benefits of OO methods.</em></p></blockquote>
<p>And little have changed since then &#8211; if anything the influence of Computerworld pundits and today&#8217;s bloggers are even larger than that of empirical and experimental research.</p>
<p>Just 15 years later, though, few of the journal issue&#8217;s articles have stood the test of time. Still, there are some anecdotes and pieces of information that are still interesting, if nothing else as a reminder of what people were thinking about OOP before it became mainstream, standard fare.</p>
<p>One quote from <a href="http://www.informaworld.com/smpp/ftinterface~db=all~content=a784766112~fulltext=713240930">Curtis</a> is still interesting for programmers changing from procedural to OO-style programming &#8211; as I guess most programmers actually still do while learning the ropes:</p>
<blockquote><p>[..] professionals may require experience on as many as three 00 projects before they become proficient in these methods. The reputed advantages ultimately occur, but not during the early projects in which programmers are on the learning curve and have difficulty capitalizing on the capabilities offered by 00 methods.</p></blockquote>
<p>Also, Herbsleb reports a few interesting facts from general cognitive psychology on how people generally understand objects, as part of a <a href="http://www.informaworld.com/smpp/content~db=all~content=a784766110">larger article on software engineering teams</a>:</p>
<blockquote><p>In careful experiments, Gentner (<strong><a href="http://groups.psych.northwestern.edu/gentner/papers/Gentner81c.pdf">1981</a></strong>;  Gentner &amp; France, 1988) showed that, when people are asked to repair a simple sentence with an anomalous subject-verb combination, they almost always change the verb and leave the noun as it is, independent of their relative positions. This suggests that people take the noun (i.e. the object) as the basic reference point. Models based on objects may be superior to models based on other primitives, such as behaviours.</p></blockquote>
<p>And object hierarchies..</p>
<blockquote><p><a href="http://www.amazon.com/Science-Words-Scientific-American-Library/dp/0716750279">Miller (1991)</a> described how nouns and verbs differ in their cognitive organizational form. Nouns &#8211; and hence the concepts associated with them &#8211; tend to be organized into hierarchically structured taxonomies, with class inclusion and part-whole relations as the most common linkages. These are also, of course, the most common relations in OO representations. In human cognition, these hierarchies tend to be fairly deep for nouns &#8211; often six to seven layers. These hierarchies support a variety of important cognitive behaviours, including the inheritance of properties from superordinate classes. In contrast, verbs tend to be organized in very flat and bushy structures. This again suggest a central place for objects, in that building inheritance hierarchies will mirror the way humans represent natural categories only if the basic builiding blocks are objects rather than processes or behaviours.</p></blockquote>
<p>And with the risk of going past what is acceptable amounts of quoting (but this is all <a href="http://en.wikipedia.org/wiki/Open_research">closed research</a>, so I have to quote it for you to read it):</p>
<blockquote><p>[..] human understanding of hierarchies tends to be organized around basic-level classes (i.e., intermediate levels of abstraction that form an anchor point for human classification and reasoning). As described by Rosch (<strong><a href="http://commonweb.unifr.ch/artsdean/pub/gestens/f/as/files/4610/9778_083247.pdf">1978</a></strong>; Rosch, Mervis, Gray, Johnson, &amp; Boyes-Braem, 1975), basic-level categories have large numbers of differentiating attributes, whereas, at leves both lower and higher, the differentiating attributes are very modest in number. [..] The tendency in generating class hierarchies for inheritance is to push attributes and behaviours as high as possible. But, to the extent that this is successful, it will lead to hierarchies radically different from those that both users and developers have naturally.</p></blockquote>
<p>The psychology papers by Gentner and Rosch seems to be very well worth a read for anyone interested in how the brain does categorization &#8220;in the wild&#8221;.  They are also freely accessible!</p>
<p>It might be forgotten, but originally a large argument in favour of OOP was improved knowledge sharing and better communication about program code between developers and with external forces. Now, you will more often hear arguments about code reuse, if OOP is ever even questioned.  Better communication and knowledge sharing appears to be the main focus of the papers in special issue, but where they also mostly fail to find hard empirical evidence.</p>
<p>As I&#8217;ve mentioned before, code understanding and knowledge sharing should be a field of far more interest for developers. That it is hard to find solid empirical evidence to base advice on in that regard is a big, under-appreciated problem!  All the examples from general cognitive psychology appears to provide direction for OO design, but without actual programming-specific experiments it is impossible to tell if that is the case.</p>
<p>And that was a blast from the past&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://p.einarsen.no/objects-and-your-brain-why-do-we-love-object-oriented-programming-so/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Variables and the roles they play</title>
		<link>http://p.einarsen.no/variables-and-the-roles-they-play/</link>
		<comments>http://p.einarsen.no/variables-and-the-roles-they-play/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 20:52:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Language]]></category>
		<category><![CDATA[Understanding Code]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[Variable roles]]></category>

		<guid isPermaLink="false">http://p.einarsen.no/?p=109</guid>
		<description><![CDATA[I promised to explain better the idea of variable roles I mentioned in the previous post about natural programming.
This is based on a finding by Finnish researcher Jorma Sajaniemi (published work), who discovered that 99% of variables in novice&#8217;s code can be categorized in to 11 different roles. These roles are variable uses every programmer [...]]]></description>
			<content:encoded><![CDATA[<p>I promised to explain better the idea of variable roles I mentioned in the previous <a href="http://p.einarsen.no/?p=86" target="_blank">post about natural programming</a>.</p>
<p>This is based on a finding by Finnish researcher Jorma Sajaniemi (<a href="http://en.scientificcommons.org/jorma_sajaniemi" target="_blank">published work</a>), who discovered that 99% of <a href="http://www.cs.joensuu.fi/~saja/var_roles/index.html" target="_blank">variables in novice&#8217;s code can be categorized in to 11 different </a><em><a href="http://www.cs.joensuu.fi/~saja/var_roles/index.html" target="_blank">roles</a>. </em>These roles are variable uses every programmer will recognize: iterators, constants, flags and so on &#8211; although in role-terminology the names somewhat differ (<em>steppers</em>, <em>fixed-values</em> and <em>one-way flags</em>, for example).  Mr. Sajaniemi has also found that these <a href="http://www.ppig.org/papers/17th-sajaniemi.pdf" target="_blank">roles matches <em>tacit </em>knowledge in expert programmers</a> &#8211; i.e. the 11 roles are also typically intuitively recognized by expert programmers even if it is not explicit or active knowledge.</p>
<p>Whether or not the same 11 variable roles are enough to categorize expert variable use seems harder to pin down, but there is a <a href="http://www.cs.joensuu.fi/~saja/var_roles/abstracts/08_Heikkila_MasterThesis.html" target="_blank">master&#8217;s thesis from their lab finding that they are sufficient</a>. And, not surprisingly, in expert-written programs, the roles have a significantly different distribution. Judge for yourself, is this enough to describe your own variables?</p>
<table class="inline" border="0" cellpadding="3">
<tbody>
<tr>
<th>Role</th>
<th>Example</th>
<th>Informal definition</th>
</tr>
<tr>
<td>Fixed value</td>
<td><tt>maxStringLength</tt></td>
<td>A data item that does not get a new proper value after its initialization</td>
</tr>
<tr>
<td>Stepper</td>
<td><tt>count</tt></td>
<td>A data item stepping through a systematic, predictable succession of values</td>
</tr>
<tr>
<td>Most-recent holder</td>
<td><tt>inputData</tt></td>
<td>A data item holding the latest value encountered in going through a succession of unpredictable values, or simply the latest value obtained as input</td>
</tr>
<tr>
<td>Most-wanted holder</td>
<td><tt>maximum</tt></td>
<td>A data item holding the best or otherwise most appropriate value encountered so far</td>
</tr>
<tr>
<td>Gatherer</td>
<td><tt>sum</tt></td>
<td>A data item accumulating the effect of individual values</td>
</tr>
<tr>
<td>Follower</td>
<td><tt>prev</tt></td>
<td>A data item that gets its new value always from the old value of some other data item</td>
</tr>
<tr>
<td>One-way flag</td>
<td><tt>errorsOccurred</tt></td>
<td>A two-valued data item that cannot get its initial value once the value has been changed</td>
</tr>
<tr>
<td>Temporary</td>
<td><tt>temp</tt></td>
<td>A data item holding some value for a very short time only</td>
</tr>
<tr>
<td>Organizer</td>
<td><tt>sortArray</tt></td>
<td>A data structure storing elements that can be rearranged</td>
</tr>
<tr>
<td>Container</td>
<td><tt>processQueue</tt></td>
<td>A data structure storing elements that can be added and removed</td>
</tr>
<tr>
<td>Walker</td>
<td><tt>currNode</tt></td>
<td>A data item traversing in a data structure</td>
</tr>
</tbody>
</table>
<p>The list is from <a href="http://www.cs.joensuu.fi/~saja/var_roles/role_intro.html" target="_blank">An introduction to the role of variables</a>, but there is also <a href="http://www.cs.joensuu.fi/~saja/var_roles/role_list.html" target="_blank">a more extensive description</a> available.</p>
<p>Sajaniemi&#8217;s aim with the research and role concept appears to be teaching programming. For Perl-programmers, it can be interesting to see an article about <a href="http://jite.org/documents/Vol6/JITEv6p199-214Nikula269.pdf" target="_blank">Teaching Python using Roles</a>, which might tell on how interesting it is for teaching Perl. Otherwise, his research in variable roles seems to revolve around a Java world.</p>
<p>What I find most exciting with this is the approach to studying and extending programming. Instead of going the computer science route, it looks at how people program, identifies interesting patterns and <strong>puts forward numbers and testable hypotheses. </strong></p>
<p><strong> </strong>Now can this be used to actually extend programming and help expert programmers?</p>
<p>My first observation is that at least five of the variables seem to all play parts in very typical loop patterns, namely <em>stepper, most-recent-holder, most-wanted-holder, gatherer </em>and<em> follower. </em>If this is such a typical way of organizing code, perhaps language design can help this &#8211; or perhaps it already does in the immutable states and for-comprehensions of functional languages such as<a href="http://en.wikipedia.org/wiki/Scala_%28programming_language%29" target="_blank"> Scala</a>, or the <a href="http://perldoc.perl.org/functions/map.html" target="_blank">map</a>, g<a href="http://perldoc.perl.org/functions/grep.html" target="_blank">rep</a> and <a href="http://hop.perl.plover.com/" target="_blank">higher-order functions in Perl</a>. Or if nothing else it may explain why expert programmers often tend more towards those constructs (or ?).</p>
<p>But if we know these are the typical ways variables are used, how about implementing variable roles (instead of types) with special functionality that simplifies and enhances what they are used for: <em>most-wanted-holders</em> that triggers events, <em>gatherers</em> and <em>followers</em> with history, <em>walkers</em> with an implicit track, <em>organizers</em> and <em>containers</em> optimized for moving elements or not and so on.</p>
<p>But if that is a good idea is hard to tell. At least in Perl, some things can be patched on with a little magical module, so it would be simple to test. I&#8217;m playing around with it, and I&#8217;ll keep you updated if something meaningful comes out of it. If you know of any other language that implements something similar, <em>please</em> leave a comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://p.einarsen.no/variables-and-the-roles-they-play/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>A natural way of programming &#8211; the way for Perl?</title>
		<link>http://p.einarsen.no/a-natural-way-of-programming-the-way-for-perl/</link>
		<comments>http://p.einarsen.no/a-natural-way-of-programming-the-way-for-perl/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 14:20:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Language]]></category>
		<category><![CDATA[Understanding Code]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Natural Language]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://p.einarsen.no/?p=86</guid>
		<description><![CDATA[When I hear people start talking about &#8220;natural&#8221; programming, easier ways of programming or making programming available to non-programmers, I get very skeptical. It makes me think of Logo and Turtle Graphics, or programming languages made to be more similar to natural language. It&#8217;s like you could make a simpler English to make it easier [...]]]></description>
			<content:encoded><![CDATA[<p>When I hear people start talking about &#8220;natural&#8221; programming, easier ways of programming or making programming available to non-programmers, I get very skeptical. It makes me think of <a href="http://en.wikipedia.org/wiki/Logo_%28programming_language%29">Logo and Turtle Graphics</a>, or programming languages made to be more <a href="http://en.wikipedia.org/wiki/Natural_language_programming" target="_blank">similar to natural language.</a> It&#8217;s like you could make a simpler English to make it easier for non-authors to write literature. So when I first read about <a href="http://www.cs.cmu.edu/~NatProg/" target="_blank">The Natural Programming Project</a>, I balked &#8211; although for no reason.</p>
<p>The researchers working on NPP certainly does approach programming with the aim of making it easier for laypeople, which seems like a turn-off. However, the output of the project is surprisingly interesting to the professional:  Lab studies scientifically testing the utility of <a href="http://perldesignpatterns.com/" target="_blank">design patterns</a> (they are not all great, it turns out), examining how time is spent during programming (35% on navigating code, 22% on reading!) and how we think during debugging (why did this happen?) &#8211; to mention some of the research from <a href="http://www.hcii.cs.cmu.edu/" target="_blank">their department at CMU</a>.</p>
<p>And then they have actually implementation advice and real software to help utilize the findings, like the Java debugging tool <a href="http://www.cs.cmu.edu/~NatProg/whyline.html" target="_blank">WhyLine</a>. You really have to see the <a href="http://www.cs.cmu.edu/~NatProg/movies/whyline-java-demo-web.mov">90 second introduction to WhyLine</a> to get the point, but to me it really opens up a whole new world of possible IDE addons intelligently interpreting your code to you.</p>
<p><a href="http://video.google.com/videoplay?docid=4084979380413345181#" target="_blank">This is a presentation from the Google Tech Talks</a> which summarizes a lot of the work they do. If you think like me on programming for novices, tolerate the first 7 minutes on making programming accessible &#8211; after that it gets good:</p>
<p><object id="VideoPlayback" style="width: 400px; height: 326px;" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100" height="100" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://video.google.com/googleplayer.swf?docid=4084979380413345181&amp;hl=nb&amp;fs=true" /><param name="allowfullscreen" value="true" /><embed id="VideoPlayback" style="width: 400px; height: 326px;" type="application/x-shockwave-flash" width="100" height="100" src="http://video.google.com/googleplayer.swf?docid=4084979380413345181&amp;hl=nb&amp;fs=true" allowfullscreen="true"></embed></object></p>
<p>A final note relating this to my current programming language of choice, Perl: When Perl was first designed, it was with a lot of thought from Larry Wall on implementing natural language conventions <em>that actually makes sense</em>, like implicit variables, rather than blindly making it like English. Currently, however, few new things in this <em>humanist</em> regard has come out in the Perl world. The largest modernizing effort in Perl is the current, long-running effort to recreate Perl with <a href="http://perl6.org/" target="_blank">Perl 6</a>. This, however, is rather playing catch-up with other dynamic languages such as <a href="http://www.ruby-lang.org/en/" target="_blank">Ruby</a> and <a href="http://www.python.org/" target="_blank">Python</a> on technical merits, losing what sets Perl aside as a particularly expressive and truly useful language, namely the natural approach.</p>
<p>At the same time, thorough, scientific study of programming such as the NPP has made serious progress past the &#8220;make programming like writing English&#8221; idea that usually plague humanist and psychological studies of programming.  If Perl wanted to build on it&#8217;s strengths, it would be better reinvented by looking at this kind of approach -how can it fulfill the <a href="http://www.c2.com/cgi/wiki?LazinessImpatienceHubris" target="_blank">virtues of a programmer</a> better for experts who are also human?</p>
<p>Not surprisingly, I have some suggestions on what I would have liked to see for a modern Perl, that differs a wee bit from what is being done now:</p>
<ul>
<li>An IDE that uses an idea such as <a href="http://www.cs.cmu.edu/~NatProg/whyline-java.html" target="_blank">WhyLine</a>.</li>
<li>An IDE with better code navigation tools &#8211; watch the video to see some ideas.</li>
<li>A compiler that compiles your bytecode into human natural language (English) &#8211; that is only meant for <a href="http://p.einarsen.no/?p=62" target="_blank">assisting reading and understanding code</a>!</li>
<li>A
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">use warnings;</div></div>
<p>that warns about constructions that are difficult to understand: do you use ! with precedence that readers understand? Do you manipulate more variables in a block than human brains can keep track of? Is your indentation following your blocks? And so on.</li>
<li>Systematic testing of all the design patterns out there. Can we get quantitative data on number of bugs, development time, maintenance effort and reading time that you can expect when using a specific pattern? Then we would be able to sort out which patterns are worth using and which will be detrimental to your product &#8211; a very helpful addition to the current pattern collections and books.</li>
<li>Variables that even closer follow their semantic use &#8211; how about having specialized iterator variables, temporary variables, variables with history and more. (I see that I have to explain this idea further in a later post&#8230; Until then, have a look at the idea of <a href="http://www.cs.joensuu.fi/~saja/var_roles/role_intro.html" target="_blank">variable roles</a>)</li>
</ul>
<p>Those are some ideas of the top of my head &#8211; and not all of them of equal merit..</p>
<p>As the NPP provides statistics on, and as most programmers know by experience, most of your time does not go into writing fresh, new code. For an expert programmer, I dare suggest the act of expressing what you want the computer to do is rarely where the challenge lies in your 9 to 5 job. A programming language and environment that starts taking that seriously would be a truly modern and enlightened language &#8211; and winning support would be like shooting fish in a barrel.</p>
<p>In the Perl world, a common criticism of the Perl 6 development is that it is a solution to a non-existing problem. The above, I suggest, is the problem that is just waiting to be solved by a modern Perl.</p>
]]></content:encoded>
			<wfw:commentRss>http://p.einarsen.no/a-natural-way-of-programming-the-way-for-perl/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
<enclosure url="http://www.cs.cmu.edu/~NatProg/movies/whyline-java-demo-web.mov" length="5369370" type="video/quicktime" />
		</item>
		<item>
		<title>How to understand a large system?</title>
		<link>http://p.einarsen.no/how-to-understand-a-large-system/</link>
		<comments>http://p.einarsen.no/how-to-understand-a-large-system/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 20:04:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Understanding Code]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Working Memory]]></category>

		<guid isPermaLink="false">http://p.einarsen.no/?p=62</guid>
		<description><![CDATA[Occasionally, programming forums take a step back from the nitty gritty implementation details and look at the bigger issues. I wish they did more often, as &#8220;occasionally&#8221; means pretty much close to never. Most discussions in technical forums rarely go past what you can find in the manual, while the big things that can make [...]]]></description>
			<content:encoded><![CDATA[<p>Occasionally, programming forums take a step back from the nitty gritty implementation details and look at the bigger issues. I wish they did more often, as &#8220;occasionally&#8221; means pretty much close to never. Most discussions in technical forums rarely go past what you can find in the manual, while the big things that can make or break a project (or a programmer) goes unmentioned.</p>
<p>So <em>Elisheva</em>&#8217;s discussion &#8220;Swallowing and Elephant in 10 easy steps&#8221; on <a href="http://www.perlmonks.org/?node_id=788328" target="_blank">how you go about to understand large, new systems</a> was a very interesting diversion at <a href="http://www.perlmonks.org/">Perl Monks</a>.  There&#8217;s only a few quality thoughts past the original posters musing, sadly, but it is nice to see someone touching this subject in a serious way. Another thought on the subject is written by <a href="http://www.visibleworkings.com/archeology/hendrickson.htm" target="_blank">Chet Hendrickson</a> who offers the suggestion of refactoring and testing for understanding.</p>
<p>Most programmers nowadays are more likely to maintain and extend existing systems than they are to design and develop new ones &#8211; at least in a professional manner. Still most programmers focus on how to write code, not read code. And most programmers write code aimed at the compiler or interpreter (which will understand anything that parses),  and not the next programmer (who must read in a non-native language and is usually <a href="http://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_or_Minus_Two" target="_blank">unable to keep track of more than seven variables at the time</a>). Perhaps it is time for an interpreter for converting code from programming languages to native human language?</p>
]]></content:encoded>
			<wfw:commentRss>http://p.einarsen.no/how-to-understand-a-large-system/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
