<?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>StubHub All Access &#187; News</title>
	<atom:link href="http://blog.stubhub.com/blog/news/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.stubhub.com/blog</link>
	<description>By The Fans / For The Fans</description>
	<lastBuildDate>Wed, 19 Jun 2013 16:42:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Recap of StubHub&#8217;s First Annual Hackathon</title>
		<link>http://blog.stubhub.com/blog/news/first-annual-stubhub-hackathon-recap/</link>
		<comments>http://blog.stubhub.com/blog/news/first-annual-stubhub-hackathon-recap/#comments</comments>
		<pubDate>Tue, 18 Jun 2013 18:54:28 +0000</pubDate>
		<dc:creator>Rashid Aidun</dc:creator>
		
		<guid isPermaLink="false">http://blog.stubhub.com/blog/?post_type=news&#038;p=863</guid>
		<description><![CDATA[StubHub&#8217;s first ever hackathon was held on the weekend of May 17th. We had over 25 participants join us for the opening social hour Friday evening where Director of Software [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://blog.stubhub.com/blog/wp-content/uploads/2013/06/Hackathon-_1.jpg"><img class="size-medium wp-image-857 aligncenter" alt="Hackathon _1" src="http://blog.stubhub.com/blog/wp-content/uploads/2013/06/Hackathon-_1-300x197.jpg" width="300" height="197" /></a></p>
<p><a href="http://www.stubhub.com" title="StubHub's" target="_blank">StubHub&#8217;s</a> first ever <a href="http://en.wikipedia.org/wiki/Hackathon" title="Hackathon" target="_blank">hackathon </a>was held on the weekend of May 17th. We had over 25 participants join us for the opening social hour Friday evening where Director of Software Development, Mehdi Ghazizadeh, gave an introductory speech before two full nights of hacking.</p>
<p>Participants socialized briefly then formed teams. Most teams worked through both of the nights. By Sunday morning, four teams of various sizes presented ideas for prizes. Though the rules did not require it, all of the teams ended up using the StubHub and Zvents APIs.</p>
<p><a href="http://blog.stubhub.com/blog/wp-content/uploads/2013/06/hackathon-_2.jpg"><img class="size-medium wp-image-858 aligncenter" alt="hackathon _2" src="http://blog.stubhub.com/blog/wp-content/uploads/2013/06/hackathon-_2-300x97.jpg" width="300" height="97" /></a></p>
<p>The final presentations showcased awesome experiences around events:</p>
<p><strong>First place ($5,000):</strong> Scheme Zone &#8211; an application to organize &#8220;schemes&#8221; such as &#8220;the wave&#8221; at events. Collaboration involved text chat, a group video chat, and a seat map with all participants.</p>
<p><strong>Second prize ($3,000):</strong> Take Me Out &#8211; A dating application around events. Singles would log in, choose events, and the application would pair them up for a date to the event.</p>
<p><strong>Third prize ($2,000):</strong> MerchPerch &#8211; A team of six formed this merchandising experience for both sellers and buyers. Sellers had access to inventory management tools. Buyers had access to a web application to purchase merchandise at events without needing to stand in line. This team stood out on formal engineering process &#8212; they created requirements, then wireframes, then formed 3 teams of 2 to code the various components. They asked some of our engineers for API and DataModel help.</p>
<p>No prize: Rota &#8211; A music discovery application. Unfortunately for this team of two, by presentation time, very little outside of a nonfunctional menu was complete.</p>
<p><a href="http://blog.stubhub.com/blog/wp-content/uploads/2013/06/Hackathon-_-3.jpg"><img class="size-medium wp-image-856 aligncenter" alt="Hackathon _ 3" src="http://blog.stubhub.com/blog/wp-content/uploads/2013/06/Hackathon-_-3-300x134.jpg" width="300" height="134" /></a></p>
<p>It was a very energizing experience for everyone. Many thanks to the StubHub Boston engineering along with many of the folks from the San Francisco office for help making this hackathon a reality.</p>
<p>Stay tuned. More StubHub hackathons to come! Visit us on <a href="http://www.linkedin.com/company/stubhub/careers?trk=top_nav_careers" title="Linked In" target="_blank">Linked In</a> to learn more about job opportunities at StubHub.  </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stubhub.com/blog/news/first-annual-stubhub-hackathon-recap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Behind ths Scenes with Eurosport</title>
		<link>http://blog.stubhub.com/blog/news/behind-ths-scenes-with-eurosport/</link>
		<comments>http://blog.stubhub.com/blog/news/behind-ths-scenes-with-eurosport/#comments</comments>
		<pubDate>Tue, 18 Jun 2013 03:40:15 +0000</pubDate>
		<dc:creator>jackie tincher</dc:creator>
		
		<guid isPermaLink="false">http://blog.stubhub.com/blog/?post_type=news&#038;p=862</guid>
		<description><![CDATA[A great Behind the Scenes StubHub UK All Access feature with the crew from Eurosport the Aegon Championships. Click here to view more. In April, StubHub announced a new UK sporting partnership with the [...]]]></description>
				<content:encoded><![CDATA[<p>A great Behind the Scenes StubHub UK All Access feature with the crew from Eurosport the Aegon Championships.</p>
<p><a href="http://www.youtube.com/watch?v=ecHu9RRGP0I" title="Click here to view more." target="_blank"><br />
Click here to view more.</a> </p>
<p>In April, StubHub announced a new UK sporting partnership with the Lawn Tennis Association (LTA), making StubHub the official ticket marketplace for three major UK grass court tennis events: The Aegon Championships at The Queens Club, The Aegon Classic, Birmingham and The Aegon International, Eastbourne.</p>
<p>Last  week saw the first of these partnerships, The Aegon Championships at The Queens Club taking place. The tournament is widely regarded as the men’s warm up tournament to Wimbledon and we’ve been behind the scenes to share daily access at the Championships.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stubhub.com/blog/news/behind-ths-scenes-with-eurosport/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Behind the Scenes: Meet the Aegon Ball Girls</title>
		<link>http://blog.stubhub.com/blog/news/behind-the-scenes-meet-the-aegon-ball-girls/</link>
		<comments>http://blog.stubhub.com/blog/news/behind-the-scenes-meet-the-aegon-ball-girls/#comments</comments>
		<pubDate>Tue, 18 Jun 2013 03:32:50 +0000</pubDate>
		<dc:creator>jackie tincher</dc:creator>
		
		<guid isPermaLink="false">http://blog.stubhub.com/blog/?post_type=news&#038;p=861</guid>
		<description><![CDATA[StubHub All Access: Ball girls. So what&#8217;s it like being a ball girl at the Aegon Championships? With StubHub UK All Access we were able to go Behind the Scenes [...]]]></description>
				<content:encoded><![CDATA[<p>StubHub All Access: Ball girls. So what&#8217;s it like being a ball girl at the Aegon Championships? With StubHub UK All Access we were able to go Behind the Scenes and find out.<br />
<a href="http://www.youtube.com/edit?ns=1&#038;video_id=tMNed0n8h6g" title="Check out this video with the girls!"><br />
Check out this video with the girls!</a></p>
<p>In April, StubHub announced a new UK sporting partnership with the Lawn Tennis Association (LTA), making StubHub the official ticket marketplace for three major UK grass court tennis events: The Aegon Championships at The Queens Club, The Aegon Classic, Birmingham and The Aegon International, Eastbourne.</p>
<p>Last  week saw the first of these partnerships, The Aegon Championships at The Queens Club taking place. The tournament is widely regarded as the men’s warm up tournament to Wimbledon and we’ve been behind the scenes to share daily access at the Championships.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stubhub.com/blog/news/behind-the-scenes-meet-the-aegon-ball-girls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Behind the Scenes with the Aegon Transport Crew</title>
		<link>http://blog.stubhub.com/blog/news/behind-the-scenes-with-the-aegon-transport-crew/</link>
		<comments>http://blog.stubhub.com/blog/news/behind-the-scenes-with-the-aegon-transport-crew/#comments</comments>
		<pubDate>Tue, 18 Jun 2013 03:26:42 +0000</pubDate>
		<dc:creator>jackie tincher</dc:creator>
		
		<guid isPermaLink="false">http://blog.stubhub.com/blog/?post_type=news&#038;p=860</guid>
		<description><![CDATA[The StubHub UK All Access feature takes us &#8220;Behind the Scenes&#8221; with the transport crew at the Aegon Championships. Click here to view this exclusive video! In April, StubHub announced [...]]]></description>
				<content:encoded><![CDATA[<p>The StubHub UK All Access feature takes us &#8220;Behind the Scenes&#8221; with the transport crew at the Aegon Championships.<br />
<a href="http://www.youtube.com/watch?v=STAZ-RXGvXw&#038;feature=youtu.be" title="Click here to view this exclusive video!" target="_blank"><br />
Click here to view this exclusive video!</a> </p>
<p>In April, StubHub announced a new UK sporting partnership with the Lawn Tennis Association (LTA), making StubHub the official ticket marketplace for three major UK grass court tennis events: The Aegon Championships at The Queens Club, The Aegon Classic, Birmingham and The Aegon International, Eastbourne.</p>
<p>Last  week saw the first of these partnerships, The Aegon Championships at The Queens Club taking place. The tournament is widely regarded as the men’s warm up tournament to Wimbledon and we’ve been behind the scenes to share daily access at the Championships.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stubhub.com/blog/news/behind-the-scenes-with-the-aegon-transport-crew/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Behind The Scenes: Head Groundsman</title>
		<link>http://blog.stubhub.com/blog/news/behind-the-scenes-head-groundsman/</link>
		<comments>http://blog.stubhub.com/blog/news/behind-the-scenes-head-groundsman/#comments</comments>
		<pubDate>Fri, 14 Jun 2013 23:41:25 +0000</pubDate>
		<dc:creator>jackie tincher</dc:creator>
		
		<guid isPermaLink="false">http://blog.stubhub.com/blog/?post_type=news&#038;p=849</guid>
		<description><![CDATA[Today is day four of The Aegon Championships at The Queens Club and we’re pleased to share with you another exclusive glimpse behind the scenes at all the action! Do [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://blog.stubhub.com/blog/wp-content/uploads/2013/06/Aegon-Court-_-2.jpg"><img class="size-medium wp-image-851 aligncenter" alt="Aegon Court _ 2" src="http://blog.stubhub.com/blog/wp-content/uploads/2013/06/Aegon-Court-_-2-300x168.jpg" width="300" height="168" /></a></p>
<p>Today is day four of The Aegon Championships at The Queens Club and we’re pleased to share with you another exclusive glimpse behind the scenes at all the action!</p>
<p>Do you ever wonder how much work goes into the Aegon Championships courts which are widely regarded as the best in the world? Our StubHub UK All Access feature goes Behind the Scenes to speak to The Queen&#8217;s Club groundsman Graham Kimpton.</p>
<p>Click <a title="here" href="http://www.youtube.com/watch?v=ZNKfrEIfoSU&amp;feature=youtu.be" target="_blank">here</a> to view this exclusive video of what it takes to make these courts world class.</p>
<p>For tickets, please check <a title="StubHub.co.uk" href="http:/https://www.stubhub.co.uk/aegon-championships-tickets/" target="_blank">StubHub.co.uk </a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stubhub.com/blog/news/behind-the-scenes-head-groundsman/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Behind the Scenes with David Law, Aegon Media Director</title>
		<link>http://blog.stubhub.com/blog/news/behind-the-scenes-with-david-law-aegon-media-director/</link>
		<comments>http://blog.stubhub.com/blog/news/behind-the-scenes-with-david-law-aegon-media-director/#comments</comments>
		<pubDate>Thu, 13 Jun 2013 00:37:02 +0000</pubDate>
		<dc:creator>jackie tincher</dc:creator>
		
		<guid isPermaLink="false">http://blog.stubhub.com/blog/?post_type=news&#038;p=843</guid>
		<description><![CDATA[Today is day three of The Aegon Championships at The Queens Club and we’re pleased to share with you another exclusive glimpse behind the scenes at all the action! Today, [...]]]></description>
				<content:encoded><![CDATA[<p>Today is day three of <a title="The Aegon Championships" href="http://www.lta.org.uk/fans-major-events/LTA-summer-grass-court-events/AEGON-Championships/" target="_blank">The Aegon Championships</a> at <a title="The Queens Club" href="http://www.queensclub.co.uk/" target="_blank">The Queens Club</a> and we’re pleased to share with you another exclusive glimpse behind the scenes at all the action!</p>
<p>Today, Di Dougherty catches up with the Eurosport crew, who broadcast daily throughout the tournament.  <a title="Watch " href="http://www.youtube.com/watch?v=3iggrLS3zew&amp;feature=youtu.behttp://" target="_blank">Watch</a> our exclusive behind the scenes chat with Media Director, David Law.</p>
<p>In April, <a title="StubHub" href="http://www.stubhub.com" target="_blank">StubHub</a> announced a new UK sporting partnership with the <a href="http://www.lta.org.uk/" title="Lawn Tennis Association" target="_blank">Lawn Tennis Association</a> (LTA), making StubHub the official ticket marketplace for three major UK grass court tennis events: The Aegon Championships at The Queens Club, The Aegon Classic, Birmingham and The Aegon International, Eastbourne.</p>
<p>This week sees the first of these partnerships, The Aegon Championships at The Queens Club taking place. The tournament is widely regarded as the men’s warm up tournament to Wimbledon and we’ve been behind the scenes to share daily access at the Championships.</p>
<p>Check <a href="http://www.stubhub.co.uk/aegon-championships-tickets/" title="here" target="_blank">here </a>on StubHub.UK for Aegon Championship Tickets. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stubhub.com/blog/news/behind-the-scenes-with-david-law-aegon-media-director/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Behind the Scenes: Stringers at the Queens Club</title>
		<link>http://blog.stubhub.com/blog/news/behind-the-scenes-stringers-at-the-queens-club/</link>
		<comments>http://blog.stubhub.com/blog/news/behind-the-scenes-stringers-at-the-queens-club/#comments</comments>
		<pubDate>Tue, 11 Jun 2013 21:38:20 +0000</pubDate>
		<dc:creator>jackie tincher</dc:creator>
		
		<guid isPermaLink="false">http://blog.stubhub.com/blog/?post_type=news&#038;p=823</guid>
		<description><![CDATA[Today is day two of The Aegon Championships at The Queens Club and we’re pleased to share with you another exclusive glimpse behind the scenes at all the action! Today, [...]]]></description>
				<content:encoded><![CDATA[<p>Today is day two of The <a href="http://www.lta.org.uk/fans-major-events/LTA-summer-grass-court-events/AEGON-Championships/" title="Aegon Championships" target="_blank">Aegon Championships</a> at <a href="http://www.queensclub.co.uk/‎" title="The Queens Club " target="_blank">The Queens Club</a> and we’re pleased to share with you another exclusive glimpse behind the scenes at all the action!</p>
<p>Today, Di Dougherty interviews the Babolat stringing team, who work day and night to ensure that the players&#8217; rackets are tuned to perfection.</p>
<p>Click <a href="http://bit.ly/SHStringers  " title="here" target="_blank">here</a> to view this exclusive glimpse at the Stringers at work. </p>
<p>In April, StubHub announced a new UK sporting partnership with the Lawn Tennis Association (LTA), making StubHub the official ticket marketplace for three major UK grass court tennis events: The Aegon Championships at The Queens Club, The Aegon Classic, Birmingham and The Aegon International, Eastbourne.</p>
<p>This week sees the first of these partnerships, The Aegon Championships at The Queens Club taking place. The tournament is widely regarded as the men’s warm up tournament to Wimbledon and we’ve been behind the scenes to share daily access at the Championships.</p>
<p>For tickets, please visit <a href="http://www.stubhub.co.uk/aegon-championships-tickets/" title="StubHub" target="_blank">StubHub</a> now!<br />
&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stubhub.com/blog/news/behind-the-scenes-stringers-at-the-queens-club/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Toyota 5 Whys</title>
		<link>http://blog.stubhub.com/blog/news/the-toyota-5-whys/</link>
		<comments>http://blog.stubhub.com/blog/news/the-toyota-5-whys/#comments</comments>
		<pubDate>Tue, 11 Jun 2013 00:40:04 +0000</pubDate>
		<dc:creator>Quan Ding</dc:creator>
		
		<guid isPermaLink="false">http://blog.stubhub.com/blog/?post_type=news&#038;p=820</guid>
		<description><![CDATA[I was reading the book &#8220;The Lean Startup&#8221; the other day and learned about this problem solving technique called &#8220;the Toyota 5 whys&#8220;.  You can google it for the detailed [...]]]></description>
				<content:encoded><![CDATA[<p>I was reading the book &#8220;<a title="The Lean Startup" href="http://theleanstartup.com/" target="_blank">The Lean Startup</a>&#8221; the other day and learned about this problem solving technique called &#8220;<a title="" href="http://en.wikipedia.org/wiki/5_Whys" target="_blank">the Toyota 5 whys</a>&#8220;.  You can <a title="google" href="http://www.google.com/" target="_blank">google</a> it for the detailed description. Basically when you are trying to find the root cause of a problem, don&#8217;t settle when you&#8217;ve identified the cause. Instead, repeat the process to see if you can find the cause of the cause. The theory is, if you iterate this process five times, you&#8217;ll find the true root cause that you should really fix.</p>
<p>Here&#8217;s an example taken from the <a title="Wikipedia" href="http://www.wikipedia.org/http://" target="_blank">Wikipedia</a>:</p>
<p>The vehicle will not start. (the problem).</p>
<p>1. Why? &#8211; The battery is dead. (first why)<br />
2. Why? &#8211; The alternator belt is not functioning. (second why)<br />
3. Why? &#8211; The alternator belt has broken. (third why)<br />
4. Why? &#8211; The alternator belt was well beyond its useful service life and not replaced (fourth why)<br />
5. Why? &#8211; The vehicle was not maintained according to the recommended service schedule. (fifth why, a root cause)<br />
6. Why? &#8211; Replacement parts are not available because of the extreme age of the vehicle (sixth why, optional footnote)</p>
<p>Therefore, instead of just replacing the battery, what should be done is maintenance of the vehicle according to the maintenance schedule. If you just replace the battery, it will die pretty soon again since the alternator belt is still broken.</p>
<p>I realized that this technique is very useful in fixing software defects as well and that I was actually doing it subconsciously. Here are a couple of real life examples.</p>
<p>The first is when some time ago QA assigned me a bug about a NullPointerException and asked me to add null check before dereferencing the variable. Sounds easy, right? Not so fast. Looking closer at the code where the NullPointerException was thrown, I saw two problems that a null check won&#8217;t fix. First issue was that the code block encrypts some sensitive data. By just adding a null check, the code will skip the encryption, which is probably not what we want. Second issue was that the value is one of the predefined Enum constants, which shouldn&#8217;t be null to begin with. Tracing back the call stack, it turned out that there&#8217;s a new constant added to the Enum class. But the code that translates a string value into a Enum constant hasn&#8217;t been updated to handled the new enum value. So the translation code returns a null if the string maps to the new Enum value. That&#8217;s the root cause of the NPE we should fix. If we just add a null check around the code where NPE is thrown, more than likely we will just end up with a NPE again because the null value is still there and will probably be used somewhere else. Using the 5 whys approach, the process will look something like this:</p>
<p>The program throws a NullPointerException (the problem)</p>
<p>1. Why? &#8211; Because the code dereferences an Enum variable whose value is null.<br />
2. Why? &#8211; (is the value null)? Because the code that translates a string into an Enum returns null for the given input.<br />
3. Why? &#8211; Because a new constant was added to the Enum class but the translation code hasn&#8217;t been updated.</p>
<p>There&#8217;s no &#8220;5 whys&#8221; but you get the idea.</p>
<p>In another case, I was working on a production bug. The issue was that the operations team noticed a sustained 100% CPU usage in the API servers. The operations team has done the initial triage using the java thread dump. They found that the issue was caused by multiple threads accessing a HashMap, which is a static member of a class, for both reads and wites. HashMap is not thread safe. So the recommendation was to either add synchronization or use ConcurrentHashMap instead. But locking/synchronization is the evil of all scalability issues. So I&#8217;m not quite satisfied with the solution. First I wasn&#8217;t convinced that concurrency issue can lead to CPU spin. More often it&#8217;s linked to thread liveness issues (dead locks for example). But the operations people showed me some links which point out that the implementation of the HashMap DOES have a busy while loop in it (not in Openjdk 1.6 though as I checked the source code). Then I wondered what the HashMap was used for. After reading the code, it appears that the HashMap is used in a JMS listener to track the number of times a particular message has been delivered. If the count goes over a predefined threshold, the message will be ignored. So it&#8217;s essentially a in-house implementation of duplicate message detection mechanism. Unfortunately this implementation is broken. It only works in the case of a single JVM because it uses a static HashMap to store the count. But our deployment has multiple application servers and the code won&#8217;t be able to count the messages that are sent to other JVMs. Then my follow up question was why do we roll our own implementation after all? Doesn&#8217;t ActiveMQ, our message queue system, already have the duplicate detection feature built-in? So it turned out the real fix was to remove the HashMap code completely and let ActiveMQ handle the duplicates detection. Again, applying the 5 whys technique, the process will look something like this:</p>
<p>API server has 100% CPU usage (problem)</p>
<p>1. Why? Because the JMS listener code uses HashMap which isn&#8217;t thread safe.<br />
2. Why (use HashMap)? To track the number of times a message is delivered and detect duplicates<br />
3. Why? Because the developer wasn&#8217;t aware of the fact that ActiveMQ has this support built-in</p>
<p>As you can see in the examples, jumping to a solution too quickly will lead to a premature fix which does nothing but hides the real problem. The real problem will probably just resurface in a different form until it&#8217;s fixed. So next time when you think you&#8217;ve found the fix, stop and think for a moment. Ask yourself (or whoever appropriate) a few more whys to see if there&#8217;s some deeper issue lurking around.</p>
<p>Not everyone believes in this method though. Check out the criticism section of the 5 Whys on Wikipedia, which I mostly agree. But that&#8217;s not to say there&#8217;s no value in this method. People have the tendency to stop whenever they think they&#8217;ve solved the problem. Having this 5 whys mentality helps you overcome this tendency and get closer to the true root cause of a problem.</p>
<p>Last but not least, I have to admit that I haven&#8217;t applied the 5 Whys methodology to the true purpose of this method, which is to identify the process failure, or the lack of a process. &#8220;people do not fail, processes do&#8221;. So in the first example, we can keep asking whys and the real fix maybe that our QA or unit test process should be improved to catch the problem. In the second example, maybe our code review process is lacking. These are bigger issues that require a lot more collaboration and team effort. It&#8217;s a work-in-progress as we are marching toward the continuous delivery model.</p>
<p>P.S. <a title="StubHub" href="http://www.stubhub.com" target="_blank">StubHub</a> is <a title="HIRING!" href="http://www.linkedin.com/company/stubhub/careers?trk=top_nav_careers" target="_blank">HIRING!</a> Come and join us!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stubhub.com/blog/news/the-toyota-5-whys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing Code that is Unit Test Friendly</title>
		<link>http://blog.stubhub.com/blog/news/writing-code-that-is-unit-test-friendly/</link>
		<comments>http://blog.stubhub.com/blog/news/writing-code-that-is-unit-test-friendly/#comments</comments>
		<pubDate>Mon, 10 Jun 2013 23:13:02 +0000</pubDate>
		<dc:creator>Quan Ding</dc:creator>
		
		<guid isPermaLink="false">http://blog.stubhub.com/blog/?post_type=news&#038;p=818</guid>
		<description><![CDATA[Unit test code is probably just as important as the production code. Not only does it prove that your production code works as expected, it also serves as the regression [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://blog.stubhub.com/blog/wp-content/uploads/2013/06/coding_keyboard.jpg"><img class="size-medium wp-image-821 aligncenter" alt="coding_keyboard" src="http://blog.stubhub.com/blog/wp-content/uploads/2013/06/coding_keyboard-300x194.jpg" width="300" height="194" /></a></p>
<p style="text-align: left;">Unit test code is probably just as important as the production code. Not only does it prove that your production code works as expected, it also serves as the regression suite to ensure the feature is not broken in the future.  I would argue that there should be more test code than production code.  With that in mind, it pays to write your code in a way that’s easy to write unit tests for.</p>
<p style="text-align: left;">However, if you are not following the TDD approach and only start writing unit tests after you have finished coding for the feature you’re implementing, you may end up having a hard time to test your code because of the way it’s written. Here are some tips to avoid the heart attack when you start writing unit tests and find that impossible. The tips are all derived from problems I’ve seen in  our real production code.</p>
<div>
<p><b>1. Make sure the result of the method invocation is visible either through the return value or the input arguments.</b></p>
<p style="text-align: left;">Here’s an example taken out of our production code that goes against the rule above:</p>
<p style="text-align: left;"><code>public void doSomething(ValueObjectClass vo)<br />
{</code><br />
<code>    // fetch the domainObject using vo and do something</code><br />
<code>    ...<br />
domainObjectDAO.save(domainObject);<br />
}<br />
</code></p>
<p style="text-align: left;">The method doesn&#8217;t return any value. All input arguments are acting as value objects, meaning they are used only to transfer values. That means from outside of the method, nothing has changed. The change is materialized in the domainObejctDAO.save() call. In unit test code, domainObjectDAO is often a mocked object (which is the right thing to do since we want to decouple our code from external dependencies.). This makes is very difficult to verify that doSomething() is doing the right thing because we have nothing to verify against. We can’t check return values because there’s none. We can’t check the input argument value changes because they don’t change. And we can’t query database for value changes even if I want to because the mock DAO doesn&#8217;t save it into the database at all.</p>
<p style="text-align: left;">A better approach is to make doSomething() itself returns the modified object (or change the value of the input arguments, whichever is appropriate). Have another methodcallDoSomething() that calls doSomething() and domainObjectDAO.save(). So the unit test for doSomething() can verify the values are correct. And the unit test forcallDoSomething() can verify that both doSomething() anddomainObjectDAO.save() are invoked, assuming both doSomething() anddomainObjectDAO.save() are tested separately by other unit tests.</p>
<p style="text-align: left;">An even better approach, if you follow the domain driven design principle (DDD), is to move doSomething into your domain model (instead of the domain models being anemic with nothing but getters and setters). So you test your domain model’s doSomething() method without worrying about how it’s persisted. And write a service layer code which will call your domainObject.doSomething() as well as DAO.save(). To test the service layer code, you only need to verify that both doSomething() and save() are invoked. You can read more about anemic domain model <a title="here." href="http://www.martinfowler.com/bliki/AnemicDomainModel.html" target="_blank">here</a>. Unfortunately, almost all “domain” objects I see in our production code are anemic.</p>
<p style="text-align: left;">If you are unlucky that you have to deal with testing behavior that’s not visible externally as in the example I gave above, fortunately Mockito has a feature called <a title="Captor" href="http://docs.mockito.googlecode.com/hg/latest/org/mockito/Mockito.html#15" target="_blank">Captor </a>that allows you to capture the arguments that are passed to a mocked object. You can use Captor to verify the values of the domainObject. Here’s how you test the example above:</p>
<p style="text-align: left;"><code>//Alternatively, there’s also a @Captor annotation that works at class level (not within the method)<br />
ArgumentCaptor&lt;DomainObjectClass&gt; argument = ArgumentCaptor.forClass(DomainObjectClass.class);</code><br />
<code><br />
verify(mockDAO.save(argument.capture())<br />
DomainObjectClass domainObject = argument.getValue(); </code><br />
<code><br />
</code><code>//Do some verification of values in domainObject<br />
Assert.assertEquals(domainObject.getSomething(), “It works!”);</code></p>
<p style="text-align: left;"><b>2. Don’t use static method if you can avoid it</b></p>
<p style="text-align: left;">This is not a hard rule, more of a limitation of the Mockito testing framework as it doesn’t support mocking of static methods. Checkout their <a title="FAQ" href="https://code.google.com/p/mockito/wiki/FAQ" target="_blank">FAQ</a> for Mockito’s limitations. There are some test frameworks that support mocking of static methods. But based on my personal experience, Mockito is the most straightforward to use so far. So I would stick to it for as much as you can.</p>
<p style="text-align: left;">So why should I not use static method and what do I do if I’m testing legacy code that has static methods? Here’s in Mockito’s own words:</p>
<blockquote><p><b>Can I mock static methods?</b><br />
No. Mockito prefers object orientation and dependency injection over static, procedural code that is hard to understand &amp; change. If you deal with scary legacy code you can use JMockit or Powermock to mock static methods.</p></blockquote>
<p style="text-align: left;">Basically, if you’re writing new code, write it as non-static method and use dependency inject to inject singleton instance. And to test legacy static methods, use some other test framework that supports it. In my experience, I found JMockit and Mockito can co-exist in the same test code without a problem. Here’s the code to test static method using JMockit to stub the return value of a static method call:</p>
<p style="text-align: left;"><code>new NonStrictExpectations() {<br />
SomeClass mockSomeClass;<br />
{<br />
mockSomeClass.aStaticMethod(__arguments__); result = __stubbed_result__;<br />
}<br />
};<br />
</code><br />
<b>3. Try to minimize dependencies</b></p>
<p style="text-align: left;">If you write unit tests first as in TDD, or as soon as possible (when you have some code that can compile and run, with placeholders for things not implemented yet), it will help you to identify clutter-ness of your code and make your code more modular. Modular code is easier to test as there are less dependencies to satisfy. It’s quite annoying when you have to mock or stub 10 interfaces/classes for the test setup because your implementation needs them all. It’s also code smell that your implementation is difficult for other people to use since they’ll face the same problem. If you are facing this situation, think hard about how you can make your code more modular so that some dependencies are moved or removed. If your method needs 10 external dependencies, chances are your method is growing too big and you should divide it into smaller logical pieces, each with less dependencies. That makes your code easier to read and understand as well.</p>
<p style="text-align: left;">That’s all for my first ever technology blog. Phew~~ I noticed that each section is shorter than the one before it, a sign of me getting more and more mentally exhausted.  Blogging is hard!</p>
<p style="text-align: left;">P.S. <a title="StubHub" href="http://www.stubhub.com" target="_blank">Stubhub</a> <a title="HIRING" href="http://www.linkedin.com/company/stubhub/careers?trk=top_nav_careers" target="_blank">HIRING</a>! We need talent. Come and join us!</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.stubhub.com/blog/news/writing-code-that-is-unit-test-friendly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exclusive Behind the Scenes look at The Queens Club, London: Players Lounge</title>
		<link>http://blog.stubhub.com/blog/news/exclusive-behind-the-scenes-look-at-the-queens-club-london-players-lounge/</link>
		<comments>http://blog.stubhub.com/blog/news/exclusive-behind-the-scenes-look-at-the-queens-club-london-players-lounge/#comments</comments>
		<pubDate>Mon, 10 Jun 2013 21:23:08 +0000</pubDate>
		<dc:creator>jackie tincher</dc:creator>
		
		<guid isPermaLink="false">http://blog.stubhub.com/blog/?post_type=news&#038;p=815</guid>
		<description><![CDATA[In April, StubHub announced a new UK sporting partnership with the Lawn Tennis Association (LTA), making StubHub the official ticket marketplace for three major UK grass court tennis events: The [...]]]></description>
				<content:encoded><![CDATA[<p>In April, StubHub announced a new UK sporting partnership with the Lawn Tennis Association (LTA), making StubHub the official ticket marketplace for three major UK grass court tennis events: The Aegon Championships at The Queens Club, The Aegon Classic, Birmingham and The Aegon International, Eastbourne.</p>
<p>This weeks sees the first of these partnerships, The Aegon Championships at The Queens Club taking place. The tournament is widely regarded as the men&#8217;s warm up tournament to Wimbledon and we&#8217;re pleased to share an exclusive glimpse behind the scenes at the Championships.  Di Dougherty interviews the players’ concierge who gives us an insight into some of the requests he fulfills on behalf of the players competing this week.</p>
<p>Click <a title="here" href="http://www.youtube.com/watch?v=eimSjwzpNgI&amp;feature=youtu.be" target="_blank">here</a> to view an exclusive behind the scenes tour of the Player Lounge.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stubhub.com/blog/news/exclusive-behind-the-scenes-look-at-the-queens-club-london-players-lounge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
