<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://quest.windwards.net"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>Quest for improvement - teaching</title>
 <link>http://quest.windwards.net/tags/teaching</link>
 <description></description>
 <language>en</language>
<item>
 <title>How to get a servlet to answer </title>
 <link>http://quest.windwards.net/content/how-get-servlet-answer</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; property=&quot;content:encoded&quot;&gt;&lt;p&gt;The basic problem, as illustrated by this somewhat aged &lt;a href=&quot;http://account.pacip.com/jetty/doc/PathMapping.html&quot;&gt;Jetty pathSpec documentation&lt;/a&gt;, is that &quot;/&quot; is treated as &quot;/*&quot; when giving a servlet path spec. Thus, if you want to have a servlet as &quot;front page&quot; in an embedded scenario:&lt;/p&gt;
&lt;pre class=&quot;brush: java&quot;&gt;
ServletContextHandler servlets = 
    new ServletContextHandler(ServletContextHandler.SESSIONS);
servlets.addServlet(MyServlet.class, &quot;/&quot;);&lt;/pre&gt;&lt;p&gt;... that servlet will get requests for the entire URL space and no other servlet in the context will get any requests. In particular, if you want to add a DefaultServlet to serve static web pages, images and CSS, that will be tricky.&lt;/p&gt;
&lt;p&gt;The solution is to stick each servlet in its own context handler. If you do this, you can control in what order they are asked to handle the HTTP request. Thus, you can make sure it asks all other servlets before asking the greedy &quot;/&quot; servlet. Something like this:&lt;/p&gt;
&lt;pre class=&quot;brush: java&quot;&gt;
ServletContextHandler html, servlets;
servlets = new ServletContextHandler(ServletContextHandler.SESSIONS);
servlets.addServlet(MyServlet.class, &quot;/&quot;);

html = new ServletContextHandler(ServletContextHandler.SESSIONS);
ServletHolder holder = html.addServlet(DefaultServlet.class, &quot;/html/*&quot;);
holder.setInitParameter(&quot;resourceBase&quot;, &quot;./&quot;);

ContextHandlerCollection collection = new ContextHandlerCollection();
// First, try the static stuff
collection.addHandler(html);
// Then ask the greedy servlet
collection.addHandler(servlets);

Server server = new Server(8080);
server.setHandler(collection);
server.start();
server.join();&lt;/pre&gt;&lt;p&gt;The reason this works is that a context will simply &quot;pass&quot; if it does not match a certain URL.&lt;/p&gt;
&lt;p&gt;While on the subject, it is fairly annoying when developing that the context won&#039;t print tracebacks. When developing, we would prefer the error web page to contain the stack trace. This can be achieved fairly easily:&lt;/p&gt;
&lt;pre class=&quot;brush: java&quot;&gt;
ErrorHandler errorHandler = new ErrorHandler();
errorHandler.setShowStacks(true);
server.addBean(errorHandler);
&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-tags field-type-taxonomy-term-reference field-label-above&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Tags:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/quest-blog&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;quest-blog&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/java-programming&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;java-programming&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/teaching&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;teaching&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Thu, 27 Dec 2012 11:06:05 +0000</pubDate>
 <dc:creator>quest</dc:creator>
 <guid isPermaLink="false">27 at http://quest.windwards.net</guid>
 <comments>http://quest.windwards.net/content/how-get-servlet-answer#comments</comments>
</item>
<item>
 <title>What makes a good unit test?</title>
 <link>http://quest.windwards.net/content/what-makes-good-unit-test</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; property=&quot;content:encoded&quot;&gt;&lt;h2&gt;
	Motivating rant&lt;/h2&gt;
&lt;p&gt;There are numerous articles out there talking about how to write unit tests. Still, I find that they mostly assume that the reader is an accomplished developer trying to learn to write unit tests.&lt;/p&gt;
&lt;p&gt;In particular, many articles, such as &lt;a href=&quot;http://wiki.developerforce.com/page/How_to_Write_Good_Unit_Tests&quot;&gt;this one from the force.com people&lt;/a&gt;, may have the right idea, but atrocious examples. In the linked article, the getFraction() example doesn&#039;t test the behaviour of a unit, it tests the division operation of the processor! Not only is this a fairly unlikely failure, it is also highly specific to the processor the unit test is run on, and doesn&#039;t say whether it is going to work on any other processor the code is need to work on.&lt;/p&gt;
&lt;p&gt;For those who are trying to learn programming, a somewhat different approach is needed. This article tries to find an approach that work in a situation where you are trying to learn programming with a test-driven approach.&lt;/p&gt;
&lt;h2&gt;
	What is a &quot;test&quot;?&lt;/h2&gt;
&lt;p&gt;Technically, a test is a small program that tries to make certain that some part of the production software performs as expected.&lt;/p&gt;
&lt;p&gt;Simply put, each test should tell a story. This story contains&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;
		a protagonist: it may be a procedure, method, class or an object,&lt;/li&gt;
&lt;li&gt;
		(usually) supporting characters: these are typically mocked objects or methods, and&lt;/li&gt;
&lt;li&gt;
		an interesting story: this is usually a use case for a part (the so-called &quot;unit&quot;) of the system.&lt;/li&gt;
&lt;/ul&gt;&lt;h2&gt;
	So what is a &quot;unit&quot;?&lt;/h2&gt;
&lt;p&gt;Most people ask this question when they try to make sense of test-driven development. The traditional answer is that the unit is, in &lt;a href=&quot;http://en.wikipedia.org/wiki/Unit_testing&quot;&gt;Wikipedia&#039;s terms&lt;/a&gt; &quot;&lt;em&gt;the smallest testable part of an application&lt;/em&gt;.&quot; The problem is that when we write the test before the implementation, the choice of a unit is a side-effect of the narrative of the test and so does not require particular consideration.&lt;/p&gt;
&lt;h2&gt;
	So what about this story?&lt;/h2&gt;
&lt;p&gt;Without further ado:&lt;/p&gt;
&lt;pre class=&quot;brush: java&quot;&gt;
public void testWolfCanWasteHousesButNotThatOfPracticalPiglet() {
    Wolf wolf = new Wolf();
    Piglet fifer = Hamlet.lookupPiglet(&quot;&lt;i&gt;Fifer&lt;/i&gt;&quot;);
    assert !fifer.isMason(); // sanity check
    House house = fifer.getHouse();
    wolf.huffAndPuff(house);
    assert house.isRuined();
    assert house.getDoor().isOpen();

    Piglet practical = Hamlet.lookupPiglet(&quot;Practical&quot;);
    assert practical.isMason();
    house = practical.getHouse();
    wolf.huffAndPuff(house);
    assert !house.isRuined();
    assert !house.getDoor().isOpen();
}&lt;/pre&gt;&lt;p&gt;This test documents the contract between a Wolf and various piglets. Basicly, it says that a Wolf can huff and puff and blow the house down, unless the house is built by a mason.&lt;/p&gt;
&lt;p&gt;Depending on programming language and development environment, exactly how to execute a test varies. There are numerous articles detailing this for various programming language and environment. Search engines are your friends.&lt;/p&gt;
&lt;p&gt;Tests should be named for what they test. The ultimate goal of the test name is so that a developer immediately understands contract has been broken.&lt;/p&gt;
&lt;h2&gt;
	Finally&lt;/h2&gt;
&lt;p&gt;Finally, there are some &lt;a href=&quot;http://blog.stevensanderson.com/2009/08/24/writing-great-unit-tests-best-and-worst-practises/&quot;&gt;fine articles about unit testing&lt;/a&gt; out there.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-tags field-type-taxonomy-term-reference field-label-above&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Tags:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/teaching&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;teaching&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/test-driven&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;test-driven&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/quest-blog&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;quest-blog&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Thu, 12 Jul 2012 07:06:28 +0000</pubDate>
 <dc:creator>quest</dc:creator>
 <guid isPermaLink="false">21 at http://quest.windwards.net</guid>
 <comments>http://quest.windwards.net/content/what-makes-good-unit-test#comments</comments>
</item>
<item>
 <title>Metaphors for computers: the slave</title>
 <link>http://quest.windwards.net/content/metaphors-computers-slave</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; property=&quot;content:encoded&quot;&gt;&lt;p&gt;In the previous article, I proposed the &lt;a href=&quot;http://questweb.windwards.net/content/metaphors-computers-toolshop&quot;&gt;toolshop as a metaphor for a computer&lt;/a&gt;. Thinking of computers as toolshops assign them to a passive role. This was true twenty years ago, but with the advent of global networking and - particularly - with mobile computing, computers can no longer be called passive; they are becoming symbiotic. Indeed, we increasingly depend on them to remind us of what we should do, to make movie recommendations, to do a thousand boring chores we can no longer be bothered to do ourselves. So, there is need for a metaphor with a more active connotation to explain how computers colonize our reality.&lt;/p&gt;
&lt;h2&gt;
	Computers as slaves&lt;/h2&gt;
&lt;p&gt;Computers, though active, are unproblematically subservient to our will. However, they are not (yet) generally trusted to act on our behalf; they require detailed instruction and we do not treat them as equals. This makes them &lt;em&gt;slaves&lt;/em&gt;. (If they were trusted or our equals, they would be assistants.)&lt;/p&gt;
&lt;p&gt;Let us disregard for the moment the melodramatic revolt; in practice, most slaves accepted their role in their respective societies.&lt;/p&gt;
&lt;p&gt;A typical slave-based society has an abundant supply of slaves (or your society will not stay slave-based for long). Similarily, with the advent of cloud services, IaaS, PaaS and the rest, there is essentially an unlimited supply of computing available. The critical limitation of slave-based structures are how many slaves you can instruct and coordinate.&lt;/p&gt;
&lt;p&gt;There are two axes along which utility grows: attention and trust. In the extreme case, if a slave would require your full attention at all times, it would be meaningful only when the work was dangerous. Similarly, a computer program that requires your full attention at all times is useful only in special circumstances. The real utility of slaves come when they are sufficiently autonomous for you to oversee several of them, effectively multiplying your capacity.&lt;/p&gt;
&lt;p&gt;The second axis is trust. In order for slaves to be useful to you, you must trust them to act in your stead. You must trust them to continue to perform according to your instructions when your attention is directed elsewhere, and you must be able to trust them to notify you when they encounter some condition that they are not equipped to handle.&lt;/p&gt;
&lt;p&gt;Similarily, the relevant limit for a human&#039;s use of computers is in instructing them to do your bidding and to get a predictable and faithful execution.&lt;/p&gt;
&lt;p&gt;This gives us some important design principles for software:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;
		Try to require as little of the user&#039;s attention as possible, &lt;em&gt;but never guess&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;
		Make sure to keep state so the user don&#039;t have to repeat instructions unnecessarily.&lt;/li&gt;
&lt;li&gt;
		Try not to make assumptions about the number of computers available to work on a problem; good software can be empowered by adding computing power.&lt;/li&gt;
&lt;/ul&gt;&lt;h2&gt;
	Computers, however, are not human&lt;/h2&gt;
&lt;p&gt;Computers do not share many properties with humans. They can concentrate indefinitely, they are (mostly) immobile, they are not prone to cognitive cross-connection and they are not self-centered. When we instruct computers (whether we are writing software or trying to use software) we should remember these strengths and make use of them.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-tags field-type-taxonomy-term-reference field-label-above&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Tags:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/quest-blog&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;quest-blog&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/teaching&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;teaching&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Wed, 23 May 2012 11:34:41 +0000</pubDate>
 <dc:creator>quest</dc:creator>
 <guid isPermaLink="false">15 at http://quest.windwards.net</guid>
 <comments>http://quest.windwards.net/content/metaphors-computers-slave#comments</comments>
</item>
<item>
 <title>Metaphors for computers: the toolshop</title>
 <link>http://quest.windwards.net/content/metaphors-computers-toolshop</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; property=&quot;content:encoded&quot;&gt;&lt;p&gt;In order for there to be meaningful learning about computing, we need metaphors for computers. In order to learn, humans build whole networks of information pieces at once and so need some simplifications to bootstrap these networks. The most powerful such simplifications are metaphors.&lt;/p&gt;
&lt;p&gt;Thus, in order to learn about computers, we need some way of thinking about them. In this article, I propose the first such metaphor.&lt;/p&gt;
&lt;h2&gt;
	Computers as toolshops&lt;/h2&gt;
&lt;p&gt;Out of habit, we often claim that computers are tools. While superficially true, this classification is unhelpful. From calling them tools, it does not follow that they will fundamentally transform society and elevate humanity. The hammer, while tremendously useful, has not changed the world. The computer has. Also, thinking of computers as tools needlessly limits our creativity by making us think of them as finished products.&lt;/p&gt;
&lt;p&gt;I propose that we think of computers as &lt;em&gt;toolshops&lt;/em&gt;. A toolshop is a place, an environment you might say. There are numerous tools there, but the tools themselves are not the point. Rather, the creativity - the potential - embodied in the toolshop is the point. It is the same with computers. They are a large collection of tools; with Internet access, the collection is near infinite. If we learn mastery of that environment, we can change the world, or as big a piece of it as we can drag into our toolshop.&lt;/p&gt;
&lt;p&gt;A good toolshop:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;
		has numerous tools, both to examine the world and to manipulate it&lt;/li&gt;
&lt;li&gt;
		is well organised&lt;/li&gt;
&lt;li&gt;
		is general in purpose - you never know what you will need to fix or make tomorrow&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;As software developers, we will intuitively embrace this metaphor. Much as the traditional toolshop grew from the needs of a mechanic, we will shape our work environment to make us productive. But the point is this: &lt;em&gt;we must take care to preserve the toolshop for the end user&lt;/em&gt;.  The beauty of the general purpose computer is that the full toolshop is on every worker&#039;s desk and in every person&#039;s home. Just as the software developer requires a set of modular tools, the tools we develop for others should be similarly adaptable and inspiring; they should be &lt;em&gt;repurposable&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Using this metaphor, several things become clear: software tools should ...&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;
		... insinuate their purpose&lt;/li&gt;
&lt;li&gt;
		... create easily recognizable and inspectable artifacts&lt;/li&gt;
&lt;li&gt;
		... not be overly specific in its purpose&lt;/li&gt;
&lt;li&gt;
		... inspire, stimulate creativity&lt;/li&gt;
&lt;li&gt;
		(all metaphors have their limits) ... should always strive to make their effects reversible&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;You may object that your users are afraid to touch a computer, never mind taking a sledgehammer to their economic data. When placed in a toolshop, the user may be unwilling to use a hammer for fear of hitting herself on the thumb. The answer to this cannot be to pad the head of the hammer. Rather, let us hang a set of pliers by the hammer (or even fit them together with a clasp to make the hint really obvious). Generally speaking, humans react well to such &lt;em&gt;empowerment&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Of course, there are situations where software must be highly specialized, perhaps because the user is never interested in changing its purpose. For example, a concert ticket machine is just an obstacle on the user&#039;s way to seing a movie. Being fundamentally contrarian in purpose, it is highly unlikely to inspire the user&#039;s creativity. But even here we must ask hard questions on designing it; do not lightly assume that you know which use case will be the most common one. Users may want to browse what conserts will be on next week, or they may want to book a ticket for tonight. The ticket machine can be viewed as a trvel kit, a pocket toolshop.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-tags field-type-taxonomy-term-reference field-label-above&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Tags:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/quest-blog&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;quest-blog&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/teaching&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;teaching&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Mon, 27 Feb 2012 00:32:32 +0000</pubDate>
 <dc:creator>quest</dc:creator>
 <guid isPermaLink="false">14 at http://quest.windwards.net</guid>
 <comments>http://quest.windwards.net/content/metaphors-computers-toolshop#comments</comments>
</item>
</channel>
</rss>
