<?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>The Shyam &#187; Tool</title>
	<atom:link href="http://theshyam.com/category/technical/tool/feed/" rel="self" type="application/rss+xml" />
	<link>http://theshyam.com</link>
	<description>Ramblings from the Real Shyam; You know, unlike those other fake Shyams!</description>
	<lastBuildDate>Sun, 08 Jan 2012 13:07:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using Tracker for Agile projects</title>
		<link>http://theshyam.com/2009/09/using-tracker-for-agile-projects/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-tracker-for-agile-projects</link>
		<comments>http://theshyam.com/2009/09/using-tracker-for-agile-projects/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 17:31:53 +0000</pubDate>
		<dc:creator>shyam</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Tool]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[pivotal]]></category>
		<category><![CDATA[planning]]></category>
		<category><![CDATA[Stories]]></category>
		<category><![CDATA[tracker]]></category>

		<guid isPermaLink="false">http://theshyam.com/?p=203</guid>
		<description><![CDATA[I first got exposed to the Agile methodology when I took a &#8220;Thinking in Agile&#8221; course. It was a two day course, and they walked you through what it meant to be agile, the processes involved, etc. But thinking back, I fell into the same trap I did back in college. It was mostly talk, [...]]]></description>
			<content:encoded><![CDATA[<p>I first got exposed to the Agile methodology when I took a &#8220;Thinking in Agile&#8221; course. It was a two day course, and they walked you through what it meant to be agile, the processes involved, etc. But thinking back, I fell into the same trap I did back in college. It was mostly talk, and not enough action. I learn by doing, and ipso facto, nothing really stuck. One and half years later, still at google, I became part of an internal project, which needed a kick start. And lo and behold, we decided to subscribe to the agile philosophies and not half ass it as many do. And we decided to use <a href="http://www.pivotaltracker.com/" target="_blank">Tracker</a> to manage the project.</p>
<p>The basic ideologies of Agile (and Tracker) are as follows. You work in short iterations (preferably a week or two). Every iteration, the entire team gets together to talk about what got done, and what is up next. You interact directly with the customer or his proxy, who gives you things to do in the form of stories. For a company search app, a story might look something along the lines of &#8220;<em>As a product owner, I want to be able to search for a particular employee, so that I know what he works on.</em>&#8221; Notice that this story is very well defined, especially for you as a developer. It tells you the target audience, what functionality is needed and why. The why is important because sometimes (not always), you might be able to think of a better way to do something, in which case you can pipe up with said suggestion. The example project below ignores that suggestion and I didn&#8217;t spend time to change the demo to meet my suggestions.</p>
<div id="attachment_207" class="wp-caption aligncenter" style="width: 522px"><a href="http://theshyam.com/wp-content/uploads/2009/08/Tracker.jpg"><img class="size-large wp-image-207 " title="Tracker" src="http://theshyam.com/wp-content/uploads/2009/08/Tracker-1024x341.jpg" alt="Tracker screen" width="512" height="170" /></a><p class="wp-caption-text">Tracker screen</p></div>
<p>Now tracker allows you to add and move stories around. You can move a story from the <strong>Icebox</strong> (which is where stories end up by default) into the <strong>Backlog</strong>, which are the things you need to work on. You can arrange them to order them by priority (and it is all immediate, so someone else with tracker open can see those changes as they happen). Now finally, during your iteration meeting, you sit as a team, and estimate how much each story is worth.</p>
<p>The most important point here is that <strong><em>clients are the only ones allowed to request stories</em></strong> (though you can probably figure out exceptions if you really think that some chores should get points). Customers get to decide what stories need to happen, and what order they need to happen in. Nothing more, nothing else. Now as <strong><em>developers</em></strong>, your role is to <strong><em>estimate how long</em></strong> it will take for the items in order. You can start off with some estimates like, &#8220;A point is one days work.&#8221; initially, when you are new. You can play <a href="http://en.wikipedia.org/wiki/Planning_poker">planning poker</a> to estimate, which is a fun little activity in itself to make sure no one is influenced by anyone else&#8217;s estimates. Now what tracker will do is it will measure how many stories you end up actually delivering per week, and calculate what we call your <strong>Average Velocity</strong> (pointed out in the screenshot above). This basically denotes how much tracker thinks you can do in the next iteration, assuming that your estimate base remains constant.</p>
<p>Another important thing to note, that only things that the customer cares about, or is customer facing, should be stories. These are thing the customer can see when delivered and brings value to him. So that refactoring you need to do to come out of that hole you dug for yourself? Guess what, its a chore and does not contribute to your velocity. Want to move database schemas to make it easier for yourself? Fixing that bug you introduced in trying to rush through all the stories? The customer doesn&#8217;t care (well he probably cares about the bugs, but you are not delivering value, you are cleaning up after your own mistakes), so no cookies nor any points for you.</p>
<p>So a basic flow for an iteration (after estimations and planning poker) is as follows ;</p>
<ol>
<li>Customer / Product owner prioritizes stories / chores / bugs in the backlog</li>
<li>Tracker looks at average velocity and figures out how many it can squeeze into the next iteration</li>
<li>Developers click <strong>start</strong> on a story / task when they start to work on it.</li>
<li>They click <strong>finish</strong> when they are done implementing on it, but <strong>do not</strong> click on Deliver</li>
<li>Pushmaster / Release Engineer clicks <strong>Deliver</strong> when those changes are pushed to a customer visible place</li>
<li>Customer gets to try out each story, and then can decide whether it meets specifications, and decides if he wants to <strong>accept / reject</strong>.</li>
</ol>
<p>Rinse and repeat, and you have a great way of managing requirements, release plans and so much more. You can figure out who&#8217;s working on what, you also get a great host of charting, including burndown charts, charts which allow you to figure out where you are spending the majority of time (whether stories, bugs, chores, etc). Example chart below :</p>
<div id="attachment_208" class="wp-caption aligncenter" style="width: 708px"><a href="http://theshyam.com/wp-content/uploads/2009/08/BurndownChart-1.jpg"><img class="size-full wp-image-208" title="Burndown Chart" src="http://theshyam.com/wp-content/uploads/2009/08/BurndownChart-1.jpg" alt="An example burndown chart from Tracker" width="698" height="428" /></a><p class="wp-caption-text">An example burndown chart from Tracker</p></div>
<p>Did I mention Tracker is currently free to sign up and start using? Regardless of whether you are a product manager who wants to keep his project in line, a developer interested in using agile practices, or just plain curious about what this thing is all about, Tracker has something for everyone. So, what are you waiting for, a personal invitation? You don&#8217;t need to be an Agile team to try this out for yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://theshyam.com/2009/09/using-tracker-for-agile-projects/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Super fast JS Testing</title>
		<link>http://theshyam.com/2009/08/super-fast-js-testing/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=super-fast-js-testing</link>
		<comments>http://theshyam.com/2009/08/super-fast-js-testing/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 16:42:43 +0000</pubDate>
		<dc:creator>shyam</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Tool]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[jstestdriver]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://theshyam.com/?p=164</guid>
		<description><![CDATA[Before I jump into how exactly you can perform super fast and easy JS testing, let me give you some background on the problem. Javascript is a finicky language (Some people even hesitate to call it a language). And it can easily grow and become a horrible and complicated beast, incapable of being tamed once [...]]]></description>
			<content:encoded><![CDATA[<p>Before I jump into how exactly you can perform super fast and easy JS testing, let me give you some background on the problem.</p>
<p>Javascript is a finicky language (Some people even hesitate to call it a language). And it can easily grow and become a horrible and complicated beast, incapable of being tamed once let loose. And testing it is a nightmare. Once you have decided on a framework (of which there are a dime a dozen), you then have to set it up to run just right. You need to set it up to actually run your tests. Then you have to figure out how to run it in a continuous integration environment. Maybe even run it in headless mode. And everyone solves it in their own ways.</p>
<p>But the biggest problem I have with most of these frameworks is that executing the tests usually requires a context switch. By that, I mean to run a JSUnit test, you end up usually having to open the browser, browse to a particular url or html page which then runs the test. Then you have to look at the results there, and then come back to your editor to either proceed further or fix your tests. Works, but really slows down development.</p>
<p>In java, all it takes is to click the run button in your IDE to run your tests. You get instant feedback, a green / red bar and details on which tests passed and failed and at what line. No context switch, you can get it to run at every save, and proceed on your merry way. Till now, this was not possible with Javascript.</p>
<p>But now, we have <a href="http://code.google.com/p/js-test-driver/" target="_blank">JS Test Driver</a>. My colleagues Jeremie and <a href="http://misko.hevery.com" target="_blank">Misko</a> ended up running into some of the issues I outlined above, and decided that going along with the flow was simply unacceptable. So they created a JS Testing framework which solves these very things. You can capture any browser on any machine, and when you tell it to run tests, it will go ahead and execute them on all these browsers and return you the results in your client. And its blazing fast. I am talking milliseconds to run 100 odd tests. And you can tell it to rerun your tests at each save. All within the comforts of your IDE. And over the last three weeks, I have been working on the eclipse plugin for JS Test Driver, and its now at the point where its in a decent working condition.</p>
<div id="attachment_165" class="wp-caption aligncenter" style="width: 438px"><a href="http://theshyam.com/wp-content/uploads/2009/08/JS-Test-Driver-Plugin.png"><img class="size-full wp-image-165" title="JS Test Driver Plugin" src="http://theshyam.com/wp-content/uploads/2009/08/JS-Test-Driver-Plugin.png" alt="The plugin in action" width="428" height="478" /></a><p class="wp-caption-text">The plugin in action</p></div>
<p>The plugin allows you to, from within Eclipse, start the JS Test Driver server, capture some browsers, and then run your tests. You get pretty icons telling you what browsers were captured, the state of the server, the state of the tests. It allows you to filter and show only failures, rerun your last launch configuration, even setup the paths to your browsers so you can launch it all from the safety of eclipse. And as you can see, its super fast. <strong><em>Some 100 odd tests in less than 10 ms</em></strong>. If thats not fast, I don&#8217;t know what is.</p>
<p>For more details on JS Test Driver, visit its <a href="http://code.google.com/p/js-test-driver/" target="_blank">Google Code</a> website and see how you can use it in your next project and even integrate it into a continuous integration. Misko talks a little bit more about the motivations behind writing it on his <a href="http://misko.hevery.com/2009/05/22/yet-another-javascript-testing-framework/" target="_blank">Yet Another JS Testing Framework</a> post. To try out the plugin for yourselves, go add the following update site to eclipse : <strong>http://js-test-driver.googlecode.com/svn/update/</strong>. For all you IntelliJ fanatics, there is something similar in the works.</p>
]]></content:encoded>
			<wfw:commentRss>http://theshyam.com/2009/08/super-fast-js-testing/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Gathering Rapid Feedback with TDD, better known as Infinitest!</title>
		<link>http://theshyam.com/2009/08/gathering-rapid-feedback-with-tdd-better-known-as-infinitest/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gathering-rapid-feedback-with-tdd-better-known-as-infinitest</link>
		<comments>http://theshyam.com/2009/08/gathering-rapid-feedback-with-tdd-better-known-as-infinitest/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 17:38:39 +0000</pubDate>
		<dc:creator>shyam</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Tool]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[infinitest]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[unit test]]></category>

		<guid isPermaLink="false">http://theshyam.com/?p=144</guid>
		<description><![CDATA[So I have had this question often, especially from TDDers, on what the best way is to get rapid feedback as you type. One of the biggest things when you do Test Driven Development is the fact that you can see a Red / Green bar or some sort of indicator of your tests. Because [...]]]></description>
			<content:encoded><![CDATA[<p>So I have had this question often, especially from TDDers, on what the best way is to get rapid feedback as you type. One of the biggest things when you do Test Driven Development is the fact that you can see a Red / Green bar or some sort of indicator of your tests. Because that indicator is what tells you what you should be doing. Green bar? Time to write a failing test so you can add that next feature in. Red bar? Well, you know what is broken, so time to go ahead and write that feature. So initially, I used to just hit <strong>Alt + Shift + X, T</strong> to run the test I was currently editing. And then I learnt the joys of <strong>Ctrl + F11</strong>, which re runs your last configuration.</p>
<p>But still, I was left wanting more. I mean, I don&#8217;t want to have to hit something to tell eclipse to go run my tests. Eclipse already knows when I save, as it can automatically shoot off a build. Why couldn&#8217;t I just have another step afterwards which then runs my test, so I don&#8217;t have to do anything? It was along this line of thought that I stumbled upon <a title="Misko" href="http://misko.hevery.com" target="_blank">Misko</a>&#8216;s setup of using build steps to <a href="http://misko.hevery.com/2009/05/07/configure-your-ide-to-run-your-tests-automatically/" target="_blank">run all unit tests at each save</a>. Hallelujah! But the more I used this, the more I started realizing its pain points. You actually had to setup each project to do this? Uh, no. Not happening. Too much effort. I like being lazy.</p>
<p>So then I happened upon this <a href="http://www.infinitest.org" target="_blank">Infinitest</a> thing. The description sounds promising, &#8220;<em>A continuous test runner for your JUnit tests.</em>&#8221; And what, it &#8220;<em>integrates with Eclipse and IntelliJ</em>&#8220;. And its &#8220;<em>Intelligent and runs only tests that are needed.</em>&#8221; I&#8217;m sold, where do I sign up? So I went ahead and installed it, and tried it out. And it actually seems to live up to its claim, so far. Its main configuration has a single checkbox, which basically says run Infinitest or don&#8217;t run it. Nice. And it integrates seamlessly with the problems view. Like so :</p>
<div id="attachment_149" class="wp-caption aligncenter" style="width: 584px"><a href="http://theshyam.com/wp-content/uploads/2009/08/Infinitest-results.png"><img class="size-large wp-image-149     " title="Infinitest Results" src="http://theshyam.com/wp-content/uploads/2009/08/Infinitest-results-1024x178.png" alt="Infinitest results in the problem view" width="574" height="100" /></a><p class="wp-caption-text">Infinitest results in the problem view</p></div>
<p>As can be seen above, I made a change which broke two tests. Half a second after I saved those changes, I have problem markers popping up all over my project telling me that the last thing I just did blew up some tests. I can double click on the markers, go to the exact line where the failure is, and see if it was an issue of the test being wrong or me being stupid. And in some cases, that isn&#8217;t even needed, because you know the tests shouldn&#8217;t have broken.</p>
<p>Infinitest seems to be smart enough to recognize all JUnit tests without you having to point it out, and runs only the tests that matter, and not all of it. But if you have other kinds of tests, then you might run into trouble. I am still playing around with it, and will probably update this post or add a new post later with more detailed info if I deem it necessary. But in the meantime, for those of you who want to run tests at every save, check out <a href="http://www.infinitest.org" target="_blank">Infinitest</a>. It is awesome!</p>
]]></content:encoded>
			<wfw:commentRss>http://theshyam.com/2009/08/gathering-rapid-feedback-with-tdd-better-known-as-infinitest/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Eclipse Productivity Shortcuts</title>
		<link>http://theshyam.com/2009/07/eclipse-productivity-shortcuts/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=eclipse-productivity-shortcuts</link>
		<comments>http://theshyam.com/2009/07/eclipse-productivity-shortcuts/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 15:57:02 +0000</pubDate>
		<dc:creator>shyam</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Tool]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[shortcuts]]></category>

		<guid isPermaLink="false">http://theshyam.com/?p=135</guid>
		<description><![CDATA[Do you code in Eclipse? Feel that you are not as productive as you can be, even with an IDE? Learn these simple keyboard shortcuts for eclipse which will increase your throughput to extraordinary levels. ]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Back in college, I used to be a notepad nazi, so as to say. I used to code all my giant programs solely in notepad (The most I upgraded to was to Textpad). And once I joined Google, I was apathetic to IDEs, so I just picked IntelliJ and went with it. Somewhere down the line, I attended a Testing and Refactoring workshop, and the only IDE available was Eclipse. And it was for a great reason.</p>
<p style="text-align: justify;">While the focus of the workshop was testing and refactoring, what they did do, which I applaud them for, was they showed us some awesome shortcuts. And suddenly, I was doing these insane refactorings at the blink of the eye. It was then that I started searching for and learning every eclipse shortcut that would help me be more productive. And before I knew it, I was typing 6 words a minute and coding up 100 words a minute <img src='http://theshyam.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . And I loved it.</p>
<p style="text-align: justify;">And so, today, I just wanted to share the best shortcuts that make life easier. And without further ado :</p>
<p style="text-align: justify;"><strong>Ctrl + Space </strong>: One of the two most important keyboard shortcuts that eclipse offers. This one is probably commonly known for autocomplete in eclipse, but not many people know that it is also context sensitive. For example, hitting Ctrl + Space when you are in the <strong>middle of typing</strong> will <em>show you all members and methods that begin with your text</em>. But hitting Ctrl + Space when you have <strong>nothing typed</strong> <em>shows you all members and properties available</em>. But the real eclipse masters know that, hitting Ctrl + Space when you <strong>type in for or foreach</strong> will show you autocomplete options for<em> generating a for loop or for each loop</em>. And if you do it right after you <strong>assign something to a collection</strong> or a list, it will <em>fill in the loop variables for the for each loop</em>. Autocomplete after <strong>typing in test</strong>, will allow you to <em>generate the skeleton of a JUnit test case method</em>. Autocomplete after <strong>typing in new</strong>, generates you a <em>skeleton for a new call</em>, which you can tab through and fill in. So many more uses and use cases for Ctrl + Space that can be found. You can generate / override method signatures in child classes. Just use and abuse it, and you will learn so much.</p>
<p style="text-align: justify;"><strong>Ctrl + 1</strong> : If there is just one more shortcut you remember from this post, let it be this one. The other super awesome, context sensitive shortcut in Eclipse, which is basically <strong>Quick Fix</strong>. If you have an <strong>error in a line</strong>, Ctrl + 1 will show you potential <em>options to fix it, like importing a class, or adding an argument to a method or fixing the method signature</em>. If you just do a <strong>method call which returns something</strong>, then you can hit Ctrl + 1 and ask it to <em>assign it to a new local or field variable</em>. You can hit Ctrl + 1 <strong>on a</strong> <strong>parameter to a method</strong> and <em>assign it to a field</em>. Ctrl + 1 <strong>on</strong> <strong>a variable</strong> can allow you <em>to inline it</em>, and <strong>on </strong><strong>an assignment</strong>, can allow you to<em> split up the declaration and assignment, or convert it to a field, parameter, </em>etc. It is, by far, The <strong><em>Most Awesome  Keyboard shortcut</em></strong> that you can know and use. Especially on errors!</p>
<p style="text-align: justify;"><strong>Ctrl + F11</strong> : Reruns the last run configuration that was executed. If you do TDD, then Alt + Shift + X, T followed by Ctrl + F11 is the most standard approach.</p>
<p style="text-align: justify;"><strong>Ctrl + Shift + R</strong> : Shows the Open Resource dialog. Type to filter, and jump directly between classes. I love this shortcut, and use and abuse it!</p>
<p style="text-align: justify;"><strong>Ctrl + Shift + O</strong> : Organizes Imports, and gets rid of unused imports.</p>
<p style="text-align: justify;"><strong>Ctrl + O</strong> : Shows the methods and properties of a class. You can start typing to filter and hit enter to jump to a particular signature / type. Hitting Ctrl + O again toggles showing inherited members. Very useful for jumping between sections in a class, or finding that one method you want to get to.</p>
<p style="text-align: justify;"><strong>Ctrl + T</strong> : Opens the Type Heirarchy. Shows all super classes as well as sub classes / implementing types in your class path. Very useful for jumping to an implementation class. Can be called from the class type, or even a method signature. Can toggle between Supertype and Subtype heirarchy if you hit Ctrl + T again. Again, you can type and filter once you are in this menu.</p>
<p style="text-align: justify;"><strong>Ctrl + / </strong>: Comment / Uncomment code. Single or multiple lines, depending on what you have selected. Enuff said.</p>
<p style="text-align: justify;"><strong>Alt + Shift + R</strong> : One of my most used shortcuts, Rename. It renames anything from variables to methods to even classes, renaming the class files if necessary. Also fixes all references to refer to it by the new name. Can sometimes break if there are compile errors, so watch out when you use it. You can also ask it to fix all textual references as well.</p>
<p style="text-align: justify;"><strong>Alt + Shift + M</strong> : Extract Method. Super useful method to break up a larger method into smaller chunks. If the code block you have selected does not need to return too many types, and looks reasonable as a separate method, then pulls up  a prompt where you can basically edit the method signature, including return type, method name and order and type of parameters. Very useful</p>
<p style="text-align: justify;"><strong>Alt + Shift + C</strong> : Only useful when the cursor is on a method signature, but this one allows you to refactor and change the method signature. This includes changing the return type, method name, and the parameters to the method, including order, and default values if you are introducing a new one. Automagically fixes all references to said method.</p>
<p style="text-align: justify;"><strong>Alt + Shift + L</strong> : Once you have a expression selected (a method call, or whatever), then Alt + Shift + L extracts that to a local variable. It prompts you for the name of the variable, and automatically infers the type as best as it can. Extremely useful shortcut!</p>
<p style="text-align: justify;"><strong>Alt + Shift + Up / Down</strong> : This one is a useful one. If you hit up, it selects the next biggest code block, down selects the next smallest. Useful in conjunction with refactoring shortcuts like extract local variable, extract method, etc. Useful to know.</p>
<p style="text-align: justify;"><strong>Alt + Shift + T</strong> : Brings up the Refactor menu. Depending on the context, this will show options like Rename, Move, Extract Interfaces and classes, Change Method Signature, etc. Nice to know, but not one I use very often. The ones I do use have already been listed above.</p>
<p style="text-align: justify;"><strong>Alt + Shift + S</strong> : Shows the Source menu. This includes menu options like Comment related, and the ever useful Override / Implement Methods, Generate Getters and Setters, and much more. Some of the menu options have direct shortcuts, but a lot of the generate commands don&#8217;t, so useful to know.</p>
<p style="text-align: justify;"><strong>Alt + Shift + X</strong> : Pulls up the Run menu, and shows what key you have to press to run a particular type. Now I generally use this as Alt + Shift + X, followed by T, which basically executes a JUnit Test. Fastest way to run unit tests without leaving the comfort of your keyboard.</p>
<p style="text-align: justify;"><strong>Alt + Up / Down</strong> : Moves a block of lines up or down. Rather than say, selecting, hitting Ctrl + X and then going to the place and pasting, why not just select all the lines, and use Alt + Up or Down to move them. Automatically handles indentation depending on the block. Very convenient</p>
<p style="text-align: justify;"><strong>Ctrl + D</strong> :  Nice and Simple, deletes the current line the cursor is on. If you have selected multiple lines, then they are all blown away. Much faster than selecting a line and hitting delete.</p>
<p style="text-align: justify;"><strong><em>UPDATE</em></strong>: Adding in some of the shortcuts that I forgot or were mentioned in the comments for easy finding</p>
<p style="text-align: justify;"><strong>Ctrl + L</strong> : Jump to a Line number</p>
<p style="text-align: justify;"><strong>Ctrl + Shift + T</strong> : Display available types. A better version of Ctrl + Shift + R if you are only looking for Java classes</p>
<p style="text-align: justify;"><strong>Alt + Shift + Up / Down</strong> : Duplicate selected lines above or below. Easier than hitting Ctrl + C followed by Ctrl + V</p>
<p style="text-align: justify;"><strong>Ctrl + Alt + H</strong> : This one, I didn&#8217;t know about. but pulls up the Call heirarchy, showing you all callers and users of the method under the cursor. Super useful, especially if you are refactoring.</p>
<p style="text-align: justify;"><strong>Ctrl + Shift + L</strong> : Show the list of shortcuts. You can hit it again to go in and edit your shortcuts.</p>
]]></content:encoded>
			<wfw:commentRss>http://theshyam.com/2009/07/eclipse-productivity-shortcuts/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Mock, Mock! Who&#8217;s there ?</title>
		<link>http://theshyam.com/2008/08/mock-mock-whos-there/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mock-mock-whos-there</link>
		<comments>http://theshyam.com/2008/08/mock-mock-whos-there/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 04:59:27 +0000</pubDate>
		<dc:creator>shyam</dc:creator>
				<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Tool]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[easymock]]></category>
		<category><![CDATA[fake]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mock]]></category>
		<category><![CDATA[stub]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://assertionfailed.wordpress.com/?p=31</guid>
		<description><![CDATA[The concept of mocking is not a new idea, but its one that has been gaining traction recently. But still, whenever I tell people to mock out their dependencies when they are trying to test, they look at me as if wondering what the heck I&#8217;m smoking. Well, if I was smoking something, I would [...]]]></description>
			<content:encoded><![CDATA[<p>The concept of mocking is not a new idea, but its one that has been gaining traction recently. But still, whenever I tell people to mock out their dependencies when they are trying to test, they look at me as if wondering what the heck I&#8217;m smoking. Well, if I was smoking something, I would share it. But mocking is a great thing for writing small unit tests.</p>
<p>I get usually one of the two statements / questions when I tell someone to just mock something out.</p>
<ol>
<li>Well, if I am mocking things out, then I am not really testing it, am I ? OR I don&#8217;t want to mock things out. I need to test the method&#8217;s interaction with other classes.</li>
<li>What about the mocked class ? We have to make sure it works too.</li>
</ol>
<p>Well, to number 1, I say, if by mocking things out, you have nothing but a series of expected calls and returns, and there&#8217;s no actual class specific behavior there, then does that Class really deserve to be a class ?</p>
<p>And the second part of number 1, well&#8230;. Is that really a unit test then ? Ideally, you should have a lot of unittests to make sure the class specific logic is sound, and then a few integration tests to make sure that everything is hooked up correctly.</p>
<p>And number 2&#8230; This is where you go and write unit tests for the class you have just mocked. Don&#8217;t depend on large scale integration tests to test all your classes. Write nice small unit tests which are fast and precise. The larger a test gets, the harder it is to find why a particular test broke and how.</p>
<p>So hopefully by now, I have you convinced that mocking may not be all that bad. Fine, you say, so how do I go about this mocking thing ? Glad you asked. While there are many mocking frameworks out there, I am going to just talk about EasyMock for Java. JMock is very similar and could be pretty interchangable.</p>
<p>The first requirement before you can use any mocking framework is the ability to inject mocks into your class. This is <strong>Dependency Injection</strong> at its core, without which you will have to find workarounds like protected setter methods and the like. But basically, if a class uses some Service or Database, make sure that you can override it with a Mock Database by passing it into a constructor or setting it via a method.</p>
<p>Once thats done, the first step in using a mock is <strong>creating the mock object.</strong> In EasyMock, its as simple as :</p>
<blockquote><p><em>MyClass myObject = EasyMock.createMock(MyClass.class);</em></p></blockquote>
<p>Thats it, nothing fancier than that. It helps if MyClass is an interface, but I believe EasyMock supports mocking non interface classes as well. Once you have done that, you can inject this mock object into the classes which you are testing.</p>
<p>The next step is <strong>setting expectations. </strong>For void methods, it as simple as just calling the method with the expected parameter. For example :</p>
<blockquote><p><em>myObject.myVoidMethod(&#8220;ThisStringWillBePassed&#8221;);<br />
EasyMock.expect(myObject.methodWithReturnValue(&#8220;ExpectedArg&#8221;)).andReturn(&#8220;ReturnValue&#8221;);<br />
EasyMock.replay(myObject);</em></p></blockquote>
<p>The EasyMock.replay(myObject) tells EasyMock that you are done setting expectations and that the next time a method on the object is called, treat it as an actual call. So then in your test, you proceed as normal invoking the methods you care about, and then finally, you call :</p>
<blockquote><p><em>EasyMock.verify(myObject);</em></p></blockquote>
<p>This ensures that all the <strong>expectations </strong>set on myObject were <strong>met</strong>. Now EasyMock also supports additional features like setting expectations on number of method calls, throwing exceptions, flexible argument matchers and so much more. For more information, check out the <a title="EasyMock" href="http://www.easymock.org" target="_blank">EasyMock home page</a>.</p>
<p>Now a few caveats with regards to mocking. It is very easy to degenerate some tests into what we call a <strong>mockery,</strong> where we end up testing mocks and their interaction instead of the actual class we want to test. So Don&#8217;t overuse mocks. Use them when you have to test something which depends on Database or expensive service calls. Also if your test ends up exercising a bunch of mock calls and nothing else, that might be a hint that your class really does not belong. And of course, it goes without saying that don&#8217;t mock the class you are testing.</p>
<p>Also, don&#8217;t set up Mock layers where a class which indirectly depends on some service object uses the mock layer. You should always mock the classes which your Class Under Test directly depends on, and not classes which it indirectly depends on. And sometimes, a mock might not be what you are looking for. Instead, a simple Stub or a Fake might be more useful. I might talk more on this or Dependency Injection in my next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://theshyam.com/2008/08/mock-mock-whos-there/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Testability Explorer cometh&#8230;.</title>
		<link>http://theshyam.com/2008/07/the-testability-explorer-cometh/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-testability-explorer-cometh</link>
		<comments>http://theshyam.com/2008/07/the-testability-explorer-cometh/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 19:57:00 +0000</pubDate>
		<dc:creator>shyam</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Tool]]></category>

		<guid isPermaLink="false">http://assertionfailed.wordpress.com/2008/07/28/the-testability-explorer-cometh/</guid>
		<description><![CDATA[So last time, we explored on how to find hotspots and untested code in your code base. But then you start looking at your code, and then you realize there is a reason why you didn&#8217;t test the darn thing. The code&#8217;s untestable. Whoo hoo.. Well, there is no such thing as untestable code. Or [...]]]></description>
			<content:encoded><![CDATA[<p>So last time, we explored on how to find hotspots and untested code in your code base. But then you start looking at your code, and then you realize there is a reason why you didn&#8217;t test the darn thing. The code&#8217;s untestable. Whoo hoo..</p>
<p>Well, there is no such thing as untestable code. Or rather, all untestable code can be refactored to make it much nicer and easier to test, through a variety of techniques. The first and foremost reason for untestable code ends up being &#8220;<span style="font-style:italic;">Constructor doing work.</span>&#8221; If the constructor of a class does anything more than stuff like &#8220;<span style="font-style:italic;">this.x = x</span>&#8221; or if it tries to call a constructor itself or use a *<span style="font-weight:bold;">GASP</span>* static factory, bingo, you have a problem.</p>
<p>But fixing that isn&#8217;t the target of this post. That will be covered in a later one, cause its a doozie. No, in this post, I want to talk about how to find these untestable code snippets without any manual effort. Every code base has atleast a few of these gems, which turn up being a nightmare to test, and in turn make everything depending on it a nightmare as well. Well, fear not, for the Testability Explorer cometh&#8230;</p>
<p>The <span style="font-weight:bold;">Testability Explorer </span>(<a href="http://www.testabilityexplorer.org">http://www.testabilityexplorer.org</a>) is an open source tool which looks at classes and does cyclomatic complexity analysis on it. What does that mean ? Well, it looks for things which make testing hard, like conditionals, and recursively dives in to objects it instantiates to find their testability score. In that respect, it is a static and recursive analysis of a code base. It takes all these into consideration and assigns a score to each class. Based on these scores, a class is either</p>
<ul>
<li>An excellent to test class</li>
<li>A Good class but could use some work</li>
<li>A horrible class to test, needs a lot of work.</li>
</ul>
<p>The following image, taken from the Testability Explorer website, shows a sample report generated by the tool :</p>
<p><a href="http://www.testabilityexplorer.org/img/jetty-6.x-progress.png"><img style="display: block; text-align: center; cursor: pointer; width: 400px; margin: 0 auto 10px;" src="http://www.testabilityexplorer.org/img/jetty-6.x-progress.png" border="0" alt="" /></a>As you can see, it generates html reports with bar graphs and pie charts. It can even, depending on the options you specify, allow you to dig in deep into the problem classes and find the method and line which causes you the most problem to test. This can give you great insight on deciding what classes need refactoring first to make it testable. A lot of times, fixing the most problematic one causes a ripple effect, which fixes a bunch of problems in classes depending on it.</p>
<p>Another great thing is that the Testability Explorer can take jar files, so if you don&#8217;t want to expose your code directly to it, you have an option. Though sadly, the Testability Explorer is currently only available for Java code. It stands to reason that something similar could be done for C++, though you Javascript guys are out on your own.</p>
<p>All in all, a great tool. But don&#8217;t depend solely on it. It is great as one tool in a repertoire of tools, but not just by itself. Testability Explorer is also a great way to notice trends, of whether your code is growing more testable or untestable, and other great things, just like code coverage. Though leading you to nothing more than testable code, you would be surprised at how much positive impact increased testability and tests can have on the quality of a project.</p>
<p>So go check it out. And enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://theshyam.com/2008/07/the-testability-explorer-cometh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Of EMMA&#8217;s and Eclipse&#8217;s</title>
		<link>http://theshyam.com/2008/07/of-emmas-and-eclipses-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=of-emmas-and-eclipses-2</link>
		<comments>http://theshyam.com/2008/07/of-emmas-and-eclipses-2/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 20:15:00 +0000</pubDate>
		<dc:creator>shyam</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Tool]]></category>

		<guid isPermaLink="false">http://assertionfailed.wordpress.com/2008/07/20/of-emmas-and-eclipses-2/</guid>
		<description><![CDATA[So last time I covered the joys of testing. Now if you do Test Driven Development, then you never have to worry about what you have tested and what is untested, but what about the scores of projects which aren&#8217;t developed in a TDD fashion ? How do I figure out which among my thousands [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-family:arial;">So last time I covered the joys of testing. Now if you do Test Driven Development, then you never have to worry about what you have tested and what is untested, but what about the scores of projects which aren&#8217;t developed in a TDD fashion ? How do I figure out which among my thousands of classes needs tests most urgently right now ? Is the class which usually gets the most bug fixes my prime target, or are there even worse classes that should be tested ? </span></p>
<p style="font-family:arial;">One solid easy way to identify this is to run some <strong>code coverage analysis </strong>on your code. What is code coverage, you ask ? It is one of the single most brilliant things which gives you coverage information about your code. Coverage information in this case basically provides you with knowledge on how much of your code and classes are executed by your tests, and which hotspots in your code are completely ignored by the test. Though you can run it without having a suite of tests and running your program manually, it provides the most bang for your buck (especially considering it is <strong>free</strong>) when you run it along with the tests. Code coverage tools generally provide information on a per package, per class, per method, per block and per line basis, so you can dig in as deep as you like.</p>
<p style="font-family:arial;"><strong> </strong><a title="EMMA" href="http://emma.sourceforge.net/" target="_blank"><strong>EMMA</strong></a> is a free, open source tool which allows you to generate code coverage information for Java code. And if you have some issues with providing some random tool with your source code, fear not, for you can provide it with a jar file which it can instrument and generate code coverage information for. And it generates nice Html reports if you prefer, which you can again dig into as deep as you like.</p>
<p style="font-family:arial;"><a href="http://bp2.blogger.com/_G0L5_kT8Cnc/SIOdSyiKweI/AAAAAAAAFq8/XeXTnk4i0jc/s1600-h/Code+coverage1.jpg"><img style="display:block;text-align:center;cursor:pointer;margin:0 auto 10px;" src="http://bp2.blogger.com/_G0L5_kT8Cnc/SIOdSyiKweI/AAAAAAAAFq8/XeXTnk4i0jc/s320/Code+coverage1.jpg" border="0" alt="" /></a></p>
<p style="font-family:arial;">The above image, grabbed from EMMA&#8217;s official website, shows a sample html report for a single class. Notice how nicely it highlights the class. The <strong>green lines </strong>represent code which was <strong>covered </strong>by one test or the other, the <strong>red </strong>ones were lines <strong>not </strong>covered at all and the <strong>yellow </strong>ones represent code which was <strong>partially covered</strong>. EMMA is smart enough to distinguish partial matches, as in the mutli condition statement above.</p>
<p><a href="http://bp2.blogger.com/_G0L5_kT8Cnc/SIOddDP1FwI/AAAAAAAAFrE/nRWpLZyABx8/s1600-h/Code+Coverage+class+level.jpg"><img style="display:block;text-align:center;cursor:pointer;margin:0 auto 10px;" src="http://bp2.blogger.com/_G0L5_kT8Cnc/SIOddDP1FwI/AAAAAAAAFrE/nRWpLZyABx8/s320/Code+Coverage+class+level.jpg" border="0" alt="" /></a></p>
<p style="font-family:arial;">This image, also grabbed from EMMA&#8217;s official website, shows code coverage information on a package level. Notice how it breaks down the information to a <strong>method, block and line level</strong>. So this report can be used to easily identify classes lacking in testing and allows surveyors to tackle these hotspots.</p>
<p style="font-family:arial;">To make it even easier for developers, EMMA is available as a plugin to most IDEs, including Eclipse. Available at <a title="EclEmma" href="http://www.eclemma.org/" target="_blank">EclEmma</a>. This tool can be run along with the tests to generate code coverage information. SO you can instant feedback on any new test that you have written, instead of having to come out and run EMMA separately. This can also help give you feedback on your test, to ensure that you are testing the code paths that you intended.</p>
<p style="font-family:arial;">Generally, it has been found that projects with code coverage less than 50 &#8211; 60% generally tend to have much more bugs and fixes than projects with higher coverage. And projects which are developed using TDD tend to end with high code coverage numbers, generally above 80%.</p>
<p style="font-family:arial;">But this comes with a few <strong>caveats</strong>. Even if you do attain 100% code coverage, it does not mean that your job is done. In the end, code coverage is a statistic and can be bent or twist by a knowledgeable person. A high code coverage number ensures you are hitting a lot of your code paths and your tests exercise a lot of the system, but it does not necessarily mean that you covered all possible cases nor does it mean that your source code itself is testable or maintainable. It is also entirely possible to write as few tests as possible which exercise bigger amounts of systems and don&#8217;t provide much value, rather than writing small fast unit tests which exercise just a small part of the system and still end up with good code coverage numbers.</p>
<p style="font-family:arial;">But that said, code coverage is an excellent tool when used as part of a greater set of tools to evaluate your project and can reveal startling trends about your projects. Maintaining a historical trend of how your code coverage grows is an interesting metric and can reveal the practices of your developers as well. And considering how it is free for Java, I don&#8217;t see any reason to not start using this for your projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://theshyam.com/2008/07/of-emmas-and-eclipses-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

