<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Alan C Francis</title>
 <link href="http://alancfrancis.com/atom.xml" rel="self"/>
 <link href="http://alancfrancis.com/"/>
 <updated>2009-12-04T14:39:43+00:00</updated>
 <id>http://alancfrancis.com/</id>
 <author>
   <name>Alan C Francis</name>
   <email>alancfrancis@gmail.com</email>
 </author>

 
 <entry>
   <title>Acceptance Testing Classes</title>
   <link href="http://alancfrancis.com/2009/09/21/acceptance-testing-classes.html"/>
   <updated>2009-09-21T00:00:00+00:00</updated>
   <id>http://alancfrancis.com/2009/09/21/acceptance-testing-classes</id>
   <content type="html">
&lt;p&gt;I have seen a lot of unit tests in my 10 years as an XP practitioner and coach.  I have also had a lot of debates about styles of unit testing.  The longest running of these debates is about the role of &quot;mock objects&quot; in TDD.&lt;/p&gt;

&lt;p&gt;Martin Fowler has characterised the use of mocks as &quot;interaction testing&quot; in that you are verifying that certain methods get called as a result of stimulating the object under test, rather than that the state of the object changed.&lt;/p&gt;

&lt;p&gt;I don't like this style of testing for a couple of reasons.&lt;/p&gt;

&lt;p&gt;The first reason, which will really have to be an article on it's own, is that it tends to make refactoring a lot harder than it might otherwise be.  This is due to a lot of tests that verify specific methods are called in a specific order.  The names and order of these methods can change often early in development, as well as later if a large refactoring is performed.&lt;/p&gt;

&lt;p&gt;The second is what I wanted to talk about here.&lt;/p&gt;

&lt;p&gt;When every collaborator of a class is mocked, it becomes divorced from reality.  It is truly being tested in isolation.  We verify that when this fake object pokes it in a certain way it responds by poking these other fake objects in a different way.  We have no evidence (at this point) to suggest that the object will be poked in the same ways in production.&lt;/p&gt;

&lt;p&gt;What we end up with, I think, is a set of acceptance tests for an individual class.&lt;/p&gt;

&lt;p&gt;When I mind map this I end up with &quot;waterfall&quot;.  We are designing and building and acceptance testing a class in isolation, and increasing the cost of change of that class.  We lose a holistic view of the system and are discouraged from refactoring, especially across classes.  The software becomes less soft.&lt;/p&gt;

	</content>
 </entry>
 
 <entry>
   <title>Thinking Tools</title>
   <link href="http://alancfrancis.com/2007/08/02/thinking-tools.html"/>
   <updated>2007-08-02T00:00:00+00:00</updated>
   <id>http://alancfrancis.com/2007/08/02/thinking-tools</id>
   <content type="html">
&lt;p&gt;Extreme Programming is pretty silent on how features (which we call UserStories) are gathered.   It only speaks to how those features are scheduled and planned.&lt;/p&gt;

&lt;p&gt;This is often considered a hole in the process.&lt;/p&gt;  

&lt;p&gt;When sitting with a client, figuring out what XP will mean to them and how it maps to their current process, this question often arises.&lt;/p&gt;

&lt;p&gt;It could be a prototype, it could be user flowcharts, it could even be an existing system.  Whatever it is, it's essentially outside the scope of 'XP' and so people assume that means they won't be allowed to use them any more.&lt;/p&gt;

&lt;p&gt;I beg to differ.  The fact that XP doesn't address these things is because they're going to be different for each and every organisation, even projects within that organisation.  This is good news for you, because it means you can just keep doing what you're doing if it works for you.&lt;/p&gt;

&lt;p&gt;What &lt;em&gt;might&lt;/em&gt; change, however, is how much reverence you attach to the &lt;em&gt;artefacts&lt;/em&gt; produced by these tools.&lt;/p&gt;  

&lt;p&gt;Each of the things above, and no doubt may more besides, are &quot;&lt;strong&gt;thinking tools&lt;/strong&gt;&quot; for an XP Customer, just as CRC cards, or BAML and a whiteboard are to the development team, or MS Project is to a Project Manager.&lt;/p&gt;

&lt;p&gt;The tools themselves help you organise your thoughts.  They help you think about the problem at hand.  Who could argue with using a tool that helps you?&lt;/p&gt;

&lt;p&gt;There is a problem, however.  An MS Project plan or a prototype, unlike a scribble on a whiteboard, carries with it an air of permanence.  All the artefacts produced from your thinking tools reflect the your view of the world and your understanding of the problem at the specific point of use.&lt;/p&gt;

&lt;p&gt;However, the map is not the territory.  The territory can change, and suddenly the map is out of date.&lt;/p&gt;

&lt;p&gt;The boxes and arrows are &lt;em&gt;not&lt;/em&gt; the design, that's in the code.&lt;/p&gt;

&lt;p&gt;Plans are worthless, Planning is essential. &lt;/p&gt;

&lt;p&gt;And the prototype/flowcharts are &lt;em&gt;not&lt;/em&gt; the requested feature set... that's in the code we've got now and the User Stories we have written but not yet implemented.&lt;/p&gt;

&lt;p&gt;The map only reflects the territory &lt;em&gt;at the time the map was drawn&lt;/em&gt;.  The design diagram details what the code looked like, or you plans for what it will eventually look like at the time &lt;em&gt;when it was created&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Every iteration, the structure of the code will change and invalidate the diagrams.  The customers understanding of what they want and what's possible will change and invalidate the prototype or the flowcharts. &lt;/p&gt; 

&lt;p&gt;This is a &lt;strong&gt;Good Thing&lt;/strong&gt;, as it make it much more likely that well end up where we want to, rather than where we &lt;em&gt;thought&lt;/em&gt; we'd want to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So go ahead, make your prototype.&lt;/strong&gt;  Plan your Customer Journeys and Interaction Designs.  But don't spend too much time on them, they're just a transient tool to help you figure out what the stories are.  And don't be afraid to throw them away, they're probably worthless after a couple of iterations anyway.  You'll have figured out new cool stuff to build, and new ways to do things.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Dials up to Eleven</title>
   <link href="http://alancfrancis.com/2007/06/25/dials-up-to-eleven.html"/>
   <updated>2007-06-25T00:00:00+00:00</updated>
   <id>http://alancfrancis.com/2007/06/25/dials-up-to-eleven</id>
   <content type="html">	
&lt;p&gt;Movements arise in context.  For people to gather around a shared social, artistic or aesthetic ideal, they usually need some other social 'norm' to distinguish themselves from.   Movements are as much about what they're against as what they're for.&lt;/p&gt;

&lt;p&gt;Now, that context may not be responsible for the birth of the idea, but I think it is responsible for turning someone's idea into a movement, shared by a number of people.&lt;/p&gt;

&lt;p&gt;In the case of Extreme Programming, the process was not 'created' by Kent Beck as a reaction to RUP.  RUP wasn't the problem at C3.  As far as process is concerned, XP primarily addressed shops with no process.  But by defining XP as the anti-RUP, the community turned XP from an idea into a Movement.  Giving the idea a concrete enemy, enables people to get behind it and take it to the next level.&lt;/p&gt;

&lt;p&gt;Ruby on Rails, another example of a movement in software, was born (so the story goes) from David Hansson's frustration with PHP.  Yet again, however, it's J2EE that defines Rails as a movement.  So, in both cases, a transforming idea comes along to bring &lt;em&gt;more&lt;/em&gt; discipline to a chaotic environment - no process, or PHP development.  In each case, however, what came to define the technology was the larger, more complex (theoretically more disciplined) approaches to process and software architecture. - RUP and J2EE.&lt;/p&gt;

&lt;p&gt;In both cases, I see a lever.  RUP has it set full on ceremony and documentation.  We know we need to ease back on that, but why pull the lever all the way over the way XP does ?  In the case of Rails, surely we can get lighterweight than a full J2EE stack without ditching &lt;em&gt;all&lt;/em&gt; of the configuration and flexibility ?  Why do we need to go for such a constrained solution as Rails ?  Why not Spring ?&lt;/p&gt;

&lt;p&gt;What's interesting about that lever is that it's spring loaded.  If we pull it 90 degrees, it snaps back to 45.  When we try and reduce the documentation in our process, if we try and drop 10% we'll end up with only a 1% reduction, or maybe none at all.  &lt;/p&gt;

&lt;p&gt;XP understood this and set out to pull the lever all the way over (knowing that it would slip back eventually).  By saying 'all code must be pair-programmed', it sets an ideal that we're pretty sure can't be adhered to all the time, but we set the dials to 11 knowing we might hit 9.&lt;/p&gt;

&lt;p&gt;The same hold for Rails.   When we take the J2EE stack and try and slim it down, maybe using Spring or something, we still end up with thousands of lines of XML.  The only way to really change things is to pull the lever all the way over, set the dials to 11, no configuration, no XML, no flexibility.&lt;/p&gt;

&lt;p&gt;The Extreme approach can really change things in a way that the softly-softly approach never will.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Redefining Simple</title>
   <link href="http://alancfrancis.com/2007/05/27/redefining-simple.html"/>
   <updated>2007-05-27T00:00:00+00:00</updated>
   <id>http://alancfrancis.com/2007/05/27/redefining-simple</id>
   <content type="html">&lt;p&gt;One of the main tenets of &lt;em&gt;Extreme Programming&lt;/em&gt; is that we should strive to produce 'simple code'.  Sometimes code is written simply from the outset, other times code needs to be refactored until it is simple.  In either case, it's necessary to have a working definition of simple to code or refactor to.&lt;/p&gt;

&lt;p&gt;Luckily, XP provides us with a definition.&lt;/p&gt;

&lt;p&gt;'Simple Code' meets the following criteria (this is an ordered list).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Passes all the tests&lt;/li&gt;
&lt;li&gt;Communicates it's intent&lt;/li&gt;
&lt;li&gt;Contains no duplication&lt;/li&gt;
&lt;li&gt;Has the fewest possible number of classes and methods&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's probably worth discussing each of these in turn.&lt;/p&gt;

&lt;p&gt;First off, we're not done if the code doesn't pass our tests.  Since we're Extreme Programmers, we code &lt;em&gt;test-first&lt;/em&gt;, and have a suite of unit tests for any particular piece of code we're about to check in.  If we can't get here, we shouldn't even bother looking at numbers 2-4.&lt;/p&gt;

&lt;p&gt;Secondly, communication.  This is somewhat subjective, but in essence we're looking for &lt;em&gt;good names&lt;/em&gt; for methods and variables.  Descriptive, and in keeping with any system of named we have in place.  Perhaps all our controllers are called &lt;code&gt;XXXController&lt;/code&gt;, perhaps the return variable from any method is always called &lt;code&gt;result&lt;/code&gt;.  The other thing I think is important here is reasonably short methods.&lt;/p&gt;

&lt;p&gt;Number 3, like our first item seems pretty black and white.   Either there's duplication or there isn't, right ?  But discussing the different kinds of duplication is a whole other article.  We're looking for both straight &lt;em&gt;textual&lt;/em&gt; duplication, but also &lt;em&gt;duplication of intent&lt;/em&gt;.  Duplication is a bad smell in our code and it's important that we stamp it out whenever we can.&lt;/p&gt;

&lt;p&gt;The last item in the list is almost an tiebreaker.  Given two different approaches that meet the first 3 criteria, choose the one with the least amount of code.  It's an &lt;strong&gt;ordered list&lt;/strong&gt;, so communication trumps size here.&lt;/p&gt;

&lt;p&gt;Now, this (I think) is a pretty decent working definition.  It has some fairly concrete guidelines (not rules) to code against and I do like the results I get when I work consciously with them.&lt;/p&gt;

&lt;p&gt;But it's only one definition.  Over time I've run a few experiments, trying out different 'rules'.  Seeing what happens to code if they're followed religiously.  One that I want to talk about here is named for it's Java implementation : No braces.&lt;/p&gt;

&lt;p&gt;What would happen if the only braces we allowed in our Java source was to scope classes and methods.  What would the code look like ?&lt;/p&gt;

&lt;p&gt;Here's a simple little example, somewhat adapted from Martin Fowlers canonical Refactoring example.&lt;/p&gt;

&lt;div class=&quot;codeblock&quot;&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;lineno&quot;&gt; 1&lt;/span&gt;         &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;statement&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RentalList&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rentals&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;User&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; 
&lt;span class=&quot;lineno&quot;&gt; 2&lt;/span&gt;                                 &lt;span class=&quot;n&quot;&gt;PrintWriter&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;headerRequired&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt; 3&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt; 4&lt;/span&gt;             &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;headerRequired&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt; 5&lt;/span&gt;             &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt; 6&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;========== STATEMENT ===============&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt; 7&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot; Username: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt; 8&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot; Date: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt; 9&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;====================================&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;10&lt;/span&gt;             &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;11&lt;/span&gt;             &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Iterator&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rentals&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;iterator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;hasNext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;12&lt;/span&gt;             &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;13&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;Rental&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Rental&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;14&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Title:  &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getTitle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;15&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;On:     &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getRentDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;16&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Cost:   &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getPrice&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;17&lt;/span&gt;                 &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;earnsPoints&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;18&lt;/span&gt;                 &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;19&lt;/span&gt;                     &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Points: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getPoints&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;20&lt;/span&gt;                     &lt;span class=&quot;n&quot;&gt;totalPoints&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getPoints&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;21&lt;/span&gt;                 &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;22&lt;/span&gt;             &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;23&lt;/span&gt;             &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;====================================&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;24&lt;/span&gt;             &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Total Points: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;totaPoints&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;25&lt;/span&gt;             &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;====================================&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;26&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Here's what I ended up with following my rule.  &lt;/p&gt;

&lt;div class=&quot;codeblock&quot;&gt;&lt;pre&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;lineno&quot;&gt; 1&lt;/span&gt;         &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;writeStatement&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PrintWriter&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RentalList&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rentals&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; 
&lt;span class=&quot;lineno&quot;&gt; 2&lt;/span&gt;                                 &lt;span class=&quot;n&quot;&gt;User&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;headerRequired&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt; 3&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt; 4&lt;/span&gt;             &lt;span class=&quot;n&quot;&gt;writeHeaderIfNecessary&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;headerRequired&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt; 5&lt;/span&gt;             &lt;span class=&quot;n&quot;&gt;writeRentals&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rentals&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt; 6&lt;/span&gt;             &lt;span class=&quot;n&quot;&gt;writeFooter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rentals&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt; 7&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt; 8&lt;/span&gt; 
&lt;span class=&quot;lineno&quot;&gt; 9&lt;/span&gt;         &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;writeStatementHeaderIfNecessary&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;PrintWriter&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;User&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;10&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;11&lt;/span&gt;             &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;headerRequired&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;12&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;writeHeader&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;13&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;14&lt;/span&gt; 
&lt;span class=&quot;lineno&quot;&gt;15&lt;/span&gt;         &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;writeHeader&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PrintWriter&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;User&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;16&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;17&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;========== STATEMENT ===============&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;18&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot; Username: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;19&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot; Date: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;20&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;====================================&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;21&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;22&lt;/span&gt; 
&lt;span class=&quot;lineno&quot;&gt;23&lt;/span&gt;         &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;writeRentals&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PrintWriter&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RentalList&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rentals&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;24&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;25&lt;/span&gt;             &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Iterator&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rentals&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;iterator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;hasNext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;26&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;writeRental&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Rental&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;27&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; 
&lt;span class=&quot;lineno&quot;&gt;28&lt;/span&gt; 
&lt;span class=&quot;lineno&quot;&gt;29&lt;/span&gt;         &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;writeRental&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PrintWriter&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RentalList&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rental&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;30&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;31&lt;/span&gt;             &lt;span class=&quot;n&quot;&gt;writeRentalDetails&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rental&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;32&lt;/span&gt;             &lt;span class=&quot;n&quot;&gt;writePointsIfNecessary&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rental&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;33&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;34&lt;/span&gt; 
&lt;span class=&quot;lineno&quot;&gt;35&lt;/span&gt;         &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;writeFooter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PrintWriter&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RentalList&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rentals&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;36&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;37&lt;/span&gt;             &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;====================================&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;38&lt;/span&gt;             &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Total Points: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rentals&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getTotalPoints&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;39&lt;/span&gt;             &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;====================================&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;   
&lt;span class=&quot;lineno&quot;&gt;40&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;41&lt;/span&gt; 
&lt;span class=&quot;lineno&quot;&gt;42&lt;/span&gt;         &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;writePointsIfNecessary&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PrintWriter&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Rental&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rental&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;43&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;44&lt;/span&gt;             &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rental&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;earnsPoints&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;45&lt;/span&gt;                 &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Points: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rental&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getPoints&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;lineno&quot;&gt;46&lt;/span&gt;         &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;There are, overall more lines of code, but what we end up with is interesting in a few ways.     &lt;/p&gt;

&lt;p&gt;The first interesting thing, I think, is the method length.  A lot of &lt;em&gt;very&lt;/em&gt; small methods, none really over 2 or 3 lines long.  Each method does exactly one thing.  It's a decision, a loop or a small set of sequential steps bundled into a 'job'.  &lt;/p&gt;

&lt;p&gt;The second interesting thing is that those 'job' methods are written at the same level of abstraction.  We don't see &lt;code&gt;writeHeader()&lt;/code&gt; followed by all the guts of writing the body.  Instead we see header, body, footer.&lt;/p&gt;

&lt;p&gt;The third interesting thing is that we've eliminated all &lt;em&gt;temporary variables&lt;/em&gt;.  A useful side effect is that it becomes much more apparent when methods can or should be moved between objects.  The total points in the above example seems like it needed moved to the &lt;code&gt;RentalList&lt;/code&gt;.  One more temporary variable eliminated.&lt;/p&gt;

&lt;p&gt;Now, there's obviously a few criticisms to be levelled at code like this.  Where's the work done?  Why do I have click all over the place to figure out the flow of the application?  I've heard it described as &lt;em&gt;'ravioli code'&lt;/em&gt; (as opposed to spaghetti).   Interestingly, large chunks of Smalltalk are written like this.  It's quite a common coding style in dynamic languages, although the loop method calling a singular method would most likely be done with a block.&lt;/p&gt;

&lt;p&gt;The advantages, however all depend on good names for the methods in question.   With good names, someone reading the code shouldn't have descend the method hierarchy very far to get the answers they seek.&lt;/p&gt;

&lt;p&gt;If we're interested in something in the statement footer, we can click into &lt;code&gt;writeStatementTo()&lt;/code&gt; and into &lt;code&gt;writeFooterTo()&lt;/code&gt;  we don't need to be bothered with all the implementation detail of the header and body.  It's not relevant except to understand that they are printed before the footer.  Or inside the &lt;code&gt;writeHeaderIfNecessaryTo()&lt;/code&gt; we can see a decision is made on whether to print the header.  If all we care about right now is how that decision is made, and not the actual printing we can see that clearly.&lt;/p&gt;

&lt;p&gt;One of the design techniques I was taught in college was Jackson Structured Programming.  This was focussed mostly on COBOL, and it's strategy was to turn a Data Definition into a Program Definition.  The diagrams for these definitions were box-and-arrow style, with boxes representing &lt;strong&gt;SEQUENCE&lt;/strong&gt;, &lt;strong&gt;SELECTION&lt;/strong&gt; and &lt;strong&gt;ITERATION&lt;/strong&gt;.  Sound familiar?&lt;/p&gt;

&lt;p&gt;I like this code style.   I know it's a bit extreme, but I'm an extreme programmer so that doesn't frighten me.  It makes my code really, really simple and obvious.  Each piece laid out in terms of others.  Iteration or Selection logic separate from what happens based on that logic.  &lt;/p&gt;

&lt;p&gt;Extreme Programming is based on turning the dials up to 10 on a lot of practices and then dialling down only where appropriate, so I like the idea of challenging myself by trying a coding style all the way.  I'm almost certainly not going to write all my production code that way, as sometimes code gets seriously contorted to meet the 'rule', but it's a useful exercise.&lt;/p&gt;

&lt;p&gt;Perhaps you have your own ideas of what &lt;strong&gt;simple&lt;/strong&gt; might mean?  What would happen if you tried to put those ideas into practice ?  What would happen if you tried to completely eliminate all temporary variables?  Or set a hard limit on method length of, say, 5 lines?  Try it.  You may not want to code like that all the time, but I guarantee you'll learn something about your code and maybe even yourself.&lt;/p&gt;
</content>
 </entry>
 
 
</feed>