<?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>Shaun Abram &#187; nealford</title>
	<atom:link href="http://www.shaunabram.com/tag/nealford/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shaunabram.com</link>
	<description>Java and Technology weblog</description>
	<lastBuildDate>Thu, 09 Feb 2012 18:06:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>OSCON Day1: The Productive Programmer, part 2</title>
		<link>http://www.shaunabram.com/oscon-day1-productive-programmer2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=oscon-day1-productive-programmer2</link>
		<comments>http://www.shaunabram.com/oscon-day1-productive-programmer2/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 03:12:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[bestpractice]]></category>
		<category><![CDATA[nealford]]></category>
		<category><![CDATA[oscon]]></category>
		<category><![CDATA[productivity]]></category>

		<guid isPermaLink="false">http://www.shaunabram.com/?p=921</guid>
		<description><![CDATA[The following are my notes from the second part of Neal Ford&#8216;s &#8220;The Productive Programmer&#8221; talk on best practices (see here for part1 on mechanics). Again, you can get the original slides form here. Part2: Practice 10 ways to improve your code 1. Composed Method The concept of &#8216;Composed Method&#8216; Comes from Smalltalk Best Practices [...]]]></description>
			<content:encoded><![CDATA[<p>The following are my notes from the second part of <a href="http://nealford.com/">Neal Ford</a>&#8216;s &#8220;<a href="http://www.oscon.com/oscon2010/public/schedule/detail/13834">The Productive Programmer</a>&#8221; talk on best practices (see here for <a href="http://www.shaunabram.com/oscon-day1-productive-programmer1/">part1 on mechanics</a>). Again, you can get the original slides form <a href="http://nealford.com/downloads/conferences/Productive_Programmer_Tutorial(Neal_Ford).pdf">here</a>.</p>
<p><span id="more-921"></span></p>
<h1>Part2: Practice</h1>
<p>10 ways to improve your code</p>
<h2>1. Composed Method</h2>
<p>The concept of &#8216;<a href="http://c2.com/ppr/wiki/WikiPagesAboutRefactoring/ComposedMethod.html">Composed Method</a>&#8216; Comes from<a href="http://c2.com/cgi/wiki?SmalltalkBestPracticePatterns"> Smalltalk Best Practices Patterns</a>.<br />
The concept involves dividing your programs into methods that perform one identifiable task. If you find yourself chunking a method (using blank lines) you should probably be refactoring</p>
<h4>Benefits of composed methods</h4>
<ul>
<li>Shorter methods are easier to test</li>
<li>Method names become documentation</li>
<li>Large number of cohesive methods</li>
<li>Discover reusable assets</li>
</ul>
<h2>2. Test Driven Development</h2>
<p>(And Test Driven Design!)<br />
TDD is the first consumer of your code &#8211; it makes you think abut how the rest of the world will use it</p>
<ul>
<li>Creates consumption awareness</li>
<li>Forces mocking of dependent objects</li>
<li>Naturally creates composed method</li>
</ul>
<p>Extroverted objects (e.g. where you create dependent objects in theconstructor) &#8216;reach out&#8217; to create other objects, i.e. adhoc object creation<br />
Introverted objects move object construction to a few simple places. Dependency Injection is a way to achieve introverted objects.</p>
<h2>3. Static analysis</h2>
<ul>
<li><a href="http://findbugs.sourceforge.net/">Findbugs</a> &#8211; byte code analysis</li>
<li><a href="http://pmd.sourceforge.net/">PMD</a> &#8211; Scans Java source code and looks for potential problems</li>
<li><a href="http://pmd.sourceforge.net/cpd.html">CPD</a> &#8211; Copy Paste Detector</li>
</ul>
<h2>4. Good citizenship</h2>
<h4>a) getters &#038; setter != encapsulation</h4>
<p>If user code has getter &#038; setters, it can break encapsulation too!<br />
Create atomic mutators for dependent fields<br />
e.g. Address should have a single setAddress method, not setCity &#038; setState</p>
<p>Instead, only have getters &#038; setter when you need them for other methods.<br />
And you shouldn&#8217;t have to test getters &#038; setters &#8211; will be tested through other code.</p>
<h4>b) Constructors</h4>
<p>Specific contract for how to create valid objects<br />
Q: How often is a blank object valid?<br />
A: Never!<br />
Therefore, don&#8217;t provide default constructor for domain objects<br />
Push back on frameworks that require default constructors</p>
<h4>c) Static methods</h4>
<p>One good use for static methods is completely black box use. No state involved i.e. for stateless, stand alone methods.<br />
But if you mix static &#038; state, you have problems.<br />
e.g. Singletons!<br />
Singletons are bad because&#8230;<br />
1) Mix responsibility (creation and logic)<br />
2) Untestable<br />
3) The object version of global variable</p>
<p>Avoid using Singletons and instead<br />
1) Create a plain class<br />
2) create a factory to create POJO of that class</p>
<h2>5. Yagni</h2>
<p>You Aint Gonna Need It!</p>
<ul>
<li>Discourages gold plating</li>
<li>Don&#8217;t indulge in speculative development &#8211; as that increases software entropy</li>
<li>Leads to frameworks, in a very bad sense e.g. <a href="http://avalon.apache.org/closed.html">Avalon</a> is framework to build frameworks</li>
</ul>
<p>Frameworks extracted from working code can be good.<br />
Frameworks created as speculative development are usually bad.</p>
<h2>6. Question Authority</h2>
<p>Test names are special<br />
Use underscores instead of Camel case (only for test method names though!)<br />
Much easier to read</p>
<p>APIS<br />
Use fluent interfaces<br />
Makes code readable to non-developers<br />
But this vialoates the JavaBean spec<br />
(need default constructor, all set methods must return void)<br />
Therefore can&#8217;t use JavaBeans spec for fluent interfaces</p>
<p>Summary &#8211; Know when to break the rules</p>
<h2>7. Slap</h2>
<p>Single Layer of Abstraction Principle<br />
Keep all lines of code in a method at the same level of abstraction<br />
Jumping abstraction layers makes code hard to understand<br />
(See a blog posting on this <a href="http://www.markhneedham.com/blog/2009/06/12/coding-single-level-of-abstraction-principle/">here</a>)</p>
<h2>8. Polyglot programming</h2>
<p>Consider leveraging existing platforms with languages targeted at specific problems and applications. In other words, use the right tool to get the job done.<br />
e.g. Java is bad at threading, consider Jaskell or Scala<br />
e.g. If there is schedule pressure, consider JRuby on Rails, or Grails<br />
e.g. For every day tasks done quickly, consider Groovy or Ruby. or <a href="http://swiby.codehaus.org/">Swiby</a> (Ruby / Swing)</p>
<p>&#8220;Stop banging rocks together &#038; get some work done!&#8221;</p>
<h2>9. Learn every Nuance</h2>
<p>Learn all the quirks<br />
For example, consider:</p>
<ul>
<li>Using Reflection (no longer slower). Can give elegant solutions to problems.</li>
<li>Regular expressions</li>
</ul>
<p>Learn the nuances of your tools, then tell the other people on your project.</p>
<h2>10. Anti Objects</h2>
<p>An antiobject is a kind of object that appears to essentially do the opposite of what we generally think the object should be doing.<br />
Consider using them if they bring elegant solutions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaunabram.com/oscon-day1-productive-programmer2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OSCON Day1: The Productive Programmer</title>
		<link>http://www.shaunabram.com/oscon-day1-productive-programmer1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=oscon-day1-productive-programmer1</link>
		<comments>http://www.shaunabram.com/oscon-day1-productive-programmer1/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 03:09:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[nealford]]></category>
		<category><![CDATA[oscon]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.shaunabram.com/?p=898</guid>
		<description><![CDATA[I spent the afternoon of day 1 at OSCON listen to Neal Ford give his &#8220;The Productive Programmer&#8221; talk and I have to say I loved it. I have heard Neal talk before and he is an excellent speaker: clear, funny, interesting and knowledgeable. The talk was in 2 parts: Mechanics and Practice. Below are [...]]]></description>
			<content:encoded><![CDATA[<p>I spent the afternoon of day 1 at <a href="http://www.oscon.com/oscon2010">OSCON</a> listen to <a href="http://nealford.com/">Neal Ford</a> give his &#8220;<a href="http://www.oscon.com/oscon2010/public/schedule/detail/13834">The Productive Programmer</a>&#8221; talk and I have to say I loved it. I have heard Neal talk before and he is an excellent speaker: clear, funny, interesting and knowledgeable. </p>
<p>The talk was in 2 parts: Mechanics and Practice.<br />
Below are my notes from the first part of the talk (see here for <a href="http://www.shaunabram.com/oscon-day1-productive-programmer1/">part2</a>), but you can also get the original slides form <a href="http://nealford.com/downloads/conferences/Productive_Programmer_Tutorial(Neal_Ford).pdf">here</a>. The talk is based on his book of the same name, <a href="http://www.amazon.com/Productive-Programmer-Theory-Practice-OReilly/dp/0596519788">The Productive Programmer</a>. Which is similar in theme but not to be confused with the &#8220;<a href="http://www.pragprog.com/the-pragmatic-programmer">The Pragmatic Programmer</a>&#8221; book.</p>
<p><span id="more-898"></span></p>
<h2>Part1: Mechanics</h2>
<p>1. Acceleration<br />
2. Focus<br />
4. Canonicality (applying the DRY principle)<br />
3. Automation</p>
<h3>1. Acceleration</h3>
<p>The basic premise of &#8216;acceleration&#8217; is that typing is faster than navigation and that tools, especially for repetitive tasks, are your friend.</p>
<h4>Operating System accelerators</h4>
<p>For o/s accelerators, he pointed out several useful tools:</p>
<ul>
<li>Windows: explorer address bar (alt-d shifts focus to the address bar)</li>
<li>Apple: In Finder, use apple-shift-g to go to Folder; There are also a bunch of other shortcuts like apple-shift-h = go to home directory</li>
<li>Firefox: Use the numberfox plugin &#8211; I looked in to this. I think it is <a href="https://addons.mozilla.org/en-US/firefox/addon/6420/">this </a>plugin, but unfortunately, it is only available for Firefox 1.5-2.0 <img src='http://www.shaunabram.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </li>
<li>He also suggested using smart help on Mac Leopard, but I&#8217;m not sure what this refers to&#8230;</li>
</ul>
<h4>Clipboards</h4>
<p>Neal pointed out that having only 1 clipboard with 1 entry is very limiting and suggested these tools to help:</p>
<ul>
<li>Windows: <a href="http://www.snapfiles.com/get/clcl.html">clcl</a> (infinite/100 clipboard history)</li>
<li>Mac: <a href="http://www.thornsoft.com/affiliate/iclip/index.htm">iClip</a> ($)</li>
<li>Mac: <a href="http://jumpcut.sourceforge.net/">Jumpcut</a></li>
</ul>
<h4>Directory Switching</h4>
<p>&#8216;There and back&#8217; for directory switching</p>
<ul>
<li>pushd &#8211; pushes a directory on the stack</li>
<li>popd &#8211; pops it back off</li>
</ul>
<p>(Note that these tools are also available on Windows)</p>
<h4>Command Prompts</h4>
<p>Graphical explorers better for some things, but the command line is better for others. The following are some tools to easy command prompt use:</p>
<ul>
<li>Windows: <a href="http://www.petri.co.il/add_command_prompt_here_shortcut_to_windows_explorer.htm">&#8216;Command prompt here&#8217; power toy</a> [Update: This is now available by default in Windows 7. By holding shift and right-clicking a folder, you'll see additional commands not listed on the standard menu. See <a href="http://downloadsquad.switched.com/2009/02/09/windows-7-tip-elevated-command-prompt-anywhere/">here</a> for more details]</li>
<li>Windows: <a href="http://www.codeproject.com/KB/cs/commandbar.aspx">Command prompt explorer bar</a> &#8211; This looks very cool!</li>
<li>Cygwin: <a href="http://unitstep.net/blog/2009/05/16/open-cygwin-bash-shell-here/">bash here</a></li>
<li>Mac: <a href="http://www.cocoatech.com/">Path finder</a> ($)</li>
</ul>
<h4>Prefer Keyboard to Mouse</h4>
<p>When coding, always prefer keyboard to mouse</p>
<h5>Learning shortcuts</h5>
<ul>
<li>Make yourself use the shortcut, even if you&#8217;ve found it via the menu!</li>
<li>Have someone else pester you about it &#8211; e.g. pair programmer</li>
<li>There is an app called KeyCaster than displays what keys were pressed</li>
<li>Key promoter plug in for IntelliJ</li>
<li>mousefeed for eclipse</li>
<li>Try turning off menu options! Forces you to use keyboard shortcuts</li>
<li>Use flash cards &#038; cheat sheets</li>
</ul>
<h5>Java IDE Examples</h5>
<p>All of our hierarchies are too deep, including in the file system &#038; in code.<br />
He suggested the following tools for IntelliJ: </p>
<ul>
<li>goto class (like &#8216;Open resource&#8217; in Eclipse?)</li>
<li>Can also open based on capital letter patterns</li>
<li>goto symbol (opens a class based on a symbol (e.g. var name) in it</li>
<li>introduce variable (does left hand declaration for you)</li>
<li>introduce variable redux</li>
<li>escalating selection</li>
</ul>
<h5>Templates</h5>
<p>All major IDE’s and coding text editors support templates in some form.</p>
<ul>
<li>Use templates, for example in <a href="http://www.jetbrains.com/idea/features/code_assistance.html#Live_Templates">IntelliJ</a> or <a href="http://eclipse.dzone.com/news/effective-eclipse-custom-templ">Eclipse</a> for things like parameter substitution, default values, repeating values</li>
<li>
Learn the language of your templating engine e.g. <a href="http://www.jetbrains.com/idea/features/freemarker_velocity.html">Velocity</a> in IntelliJ</li>
<li>Every time you type something for the 3rd time, templatize it!</li>
</ul>
<h5>Key macro tools</h5>
<p>Key macro tools are like templates, but at the operating system level. Use them to avoid typing the same commands over and over again.<br />
Windows: <a href="http://www.autohotkey.com/">AutoHot key</a><br />
Mac: <a href="http://www.smileonmymac.com/TextExpander/">TextTxpander</a> ($)</p>
<h3>Focus</h3>
<p>Try to avoid distractions by doing simple things like:</p>
<ul>
<li>Get a comfortable chair</li>
<li>Use dual monitors (google dual monitors and productivity to see proof!)
</li>
<li>Have monitors sitting immediately in front of you</li>
<li>Use a good keyboard &#038; mouse</li>
<li>Don&#8217;t get carpal tunnel! (http://en.wikipedia.org/wiki/Carpal_tunnel_syndrome)</li>
<li>Try moving mouse to your &#8216;bad&#8217; side, or use on left AND right side (Using the mouse on your &#8216;bad&#8217; will force you to use keyboard more and will also make you ambidextrous!)</li>
<li>Motivate yourself to learn keyboard shortcuts</li>
<li>Have admin privileges for the O/S (If you are not given permission, start a spreadsheet of all the time you waste because you can&#8217;t do what you need to due to lack of admin rights; Show your boss how much time it is wasting)</li>
</ul>
<p>In general, offices are terrible environments (too many distractions) &#8211; War rooms work better.</p>
<h4>Locus of attention</h4>
<p>Anything that happens outside your locus of attention breaks ﬂow.<br />
Flow is when you have total concentration and time disappears (&#8216;in the zone&#8217;).<br />
It is hard to get in to and easy to break (like sleep in that respect).</p>
<p>To avoid breaking flow/concentration, try:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Tweak_UI">Tweak UI</a> &#8211; A tool that allows you to easily manipulate your Windows environment. For example, you can turn of balloon tips for ever.</li>
<li>Screen dimmers &#8211; Allow you to automatically set you background to dark after a set time
<ul>
<li>Windows: <a href="http://www.techiequest.com/jedi-concentrate-fate-inactive-windows-application-in-black/">Jedi Concentrate</a></li>
<li>Mac: <a href="http://www.lachoseinteractive.net/en/products/doodim/">Doodim</a></li>
</ul>
<li>Internet blockers
<ul>
<li>Mac: <a href="getconcentrating.com">Concentrate</a>  &#8211; Have to reboot machine to unblock. Can configure to only block certain sites.</li>
<li>Windows: <a href="http://www.techiequest.com/jedi-concentrate-fate-inactive-windows-application-in-black/">Jedi Concentrate</a></li>
</ul>
</ul>
<p>The higher the level of concentration, the denser the ideas, so to maintain concentration:</p>
<ul>
<li>Turn of notications</li>
<li>Don&#8217;t keep email open &#8211; email is best done in batches (e.g. deal with at 9, noon and 3)</li>
<li>Put on headphones</li>
<li>Create office &#8220;quiet time&#8221;</li>
</ul>
<h4>Focus techniques</h4>
<h5>Search beats navigation</h5>
<p>Search is (increasingly) better than navigation, so try to replace file hierarchy navigation with search</p>
<ul>
<li>Desktop search. e.g. <a href="http://www.google.com/quicksearchbox/">Google Desktop search</a>(aka quick search box)</li>
<li><a href="http://desktop.google.com/plugins/i/indexitall.html">Larry&#8217;s &#8220;any text file&#8221; indexer</a></li>
</ul>
<h5>Rooted Views</h5>
<p>A <a href="http://nuggets.hammond-turner.org.uk/2008/12/top-tip-rooted-views.html">rooted view</a> is a specialized explorer view with a base folder that is &#8216;rooted&#8217; at the folder you specify.<br />
(on Mac, this is simply the directory shortcuts on the left hand side)</p>
<h5>Use virtual desktops</h5>
<ul>
<li><a href="http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx">virtual desktop manager</a> power toy</li>
<li><a href="http://virtuawin.sourceforge.net/">VirtualWin</a> (better?)</li>
<li><a href="http://www.apple.com/macosx/what-is-macosx/apps-and-utilities.html#spaces">Spaces</a> (built into leopard) </li>
</ul>
<h3>Canonicality</h3>
<p><a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a> &#8211; Don&#8217;t repeat yourself</p>
<h4>ORM</h4>
<p>A database schema can be made up of DDL + xml + pojo<br />
Choose 1 and generate the others from that<br />
e.g. generate xml &#038; Pojos classes from schema<br />
(If you need to add to a class&#8217;s logic, make the generated code Abstract, and the class that extends it is where the extra, custom code gets added)<br />
Or, generate the schema &#038; POJOs from Hibernate mapping files</p>
<h4>DRY Documentation</h4>
<p>e.g. generating wiki pages from subversion check in details (see SVN2Wiki)<br />
DRY Diagrams &#8211; Generate based on code<br />
DRY Schemas &#8211; Schemaspy</p>
<h3>Automation</h3>
<p>In general, don&#8217;t do by hand what you can automate!</p>
<ul>
<li>You should have a one command build (if, on a brand new machine, you can&#8217;t issue one command to get build, and another single command to build, then you have a flawed build process)</li>
<li>Continuous Integration (good for building, metrics reporting)</li>
<li>Version Control (Essential!) &#8211; Do not comment out code! Remove and use VCS.</li>
</ul>
<h4>Subverting other tools</h4>
<p>Selenium (open source tool for UAT)<br />
Includes a side project called selenium IDE<br />
Side use: Allows you to automate debugging wizard style web apps! (you need to test one page, but you need to navigate through 10 pages to get to it &#8211; use Selenium)<br />
Record your interaction the FIRST time you walk through the page<br />
Cuts debugging time!<br />
Selenium defines an interaction API for web apps<br />
Have your Q/A dept record bug discoveries</p>
<p>You almost never do anything just once</p>
<ul>
<li>Work like a craftsman, not a laborer</li>
<li>Build shims &#038; jigs</li>
<li>Building a tool takes longer, but you are building assets</li>
<li>Develop <a href="http://www.urbandictionary.com/define.php?term=bash-fu">Bash-fu</a></li>
</ul>
<h4>Why Automate?</h4>
<ul>
<li>Time sent automating can take multiple times longer but can be used multiple+ times. And can accidentally can become a major part of project!</li>
<li>Allows throw-aways to grow into assets</li>
<li>Allows unit testing, refactoring, support</li>
<li>Solving problems by hand makes you dumber!</li>
<ul>
<li>Steals concentration</li>
<li>Squanders focus</li>
</ul>
</ul>
<h4>Justifying automating</h4>
<ul>
<li>Timebox! &#8211; Set a reasonable amount of time to POC</li>
<li>Evaluate @ end of timebox</li>
<li>
Abandon if it is not working out</li>
</ul>
<h4>Analyze the ROI</h4>
<ul>
<li>How long does it take to do X times?</li>
<li>What are the consequences of doing it wrong?</li>
<li>Automation is about time saving and risk mitigation</li>
</ul>
<p>Last and by no means least &#8211; Don&#8217;t shave yaks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaunabram.com/oscon-day1-productive-programmer1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

