<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Object Mentor Blog: Challenge: How would you start this problem?</title>
    <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Challenge: How would you start this problem?</title>
      <description>&lt;p&gt;On Thursday, we&amp;#8217;re holding our first &lt;a href="http://codingdojo.org/"&gt;Coding Dojo&lt;/a&gt; at the recently opened &lt;a href="http://okccoco.com/"&gt;OkC CoCo&lt;/a&gt;. This isn&amp;#8217;t the first Coding Dojo to happen in Oklahoma City. Some time back, &lt;a href="http://davenicolette.wikispaces.com/"&gt;Dave Nicolette&lt;/a&gt; held a &lt;a href="http://davenicolette.wikispaces.com/TDD+Randori+and+Fishbowl"&gt;Randori with a Fishbowl&lt;/a&gt; at the OkC Java User&amp;#8217;s Group, and that&amp;#8217;s the format I&amp;#8217;ll be using for &lt;a href="http://schuchert.wikispaces.com/Rpn+Calculator+High+Level+Description"&gt;this problem&lt;/a&gt;. It was a blast then and I&amp;#8217;m hoping it&amp;#8217;ll be the same this time around.&lt;/p&gt;


	&lt;p&gt;This first DoJo is with C#, though I hope we manage to use several languages over time. I&amp;#8217;d like to sneak in Smalltalk as soon as we have enough of a critical mass so we don&amp;#8217;t lose people. I also plan to slowly introduce &lt;span class="caps"&gt;BDD&lt;/span&gt; (maybe not so slowly, who knows &amp;#8211; depends on the group).&lt;/p&gt;


	&lt;p&gt;The recent refactoring exercises (&lt;a href="http://blog.objectmentor.com/articles/2009/06/09/another-refactoring-exercise-design-patterns-recommended"&gt;here&lt;/a&gt; and &lt;a href="http://blog.objectmentor.com/articles/2009/06/04/refactoring-exercise"&gt;here&lt;/a&gt;), they come from &lt;a href="http://schuchert.wikispaces.com/Rpn+Calculator+High+Level+Description"&gt;this problem&lt;/a&gt;. We&amp;#8217;ll be starting from scratch, so you can probably imagine that those refactoring examples are not going to come up right away (actually probably not at all given the time).&lt;/p&gt;


	&lt;p&gt;So your challenge this time is not one of refactoring but rather one of an initial value problem. Given &lt;a href="http://schuchert.wikispaces.com/Rpn+Calculator+High+Level+Description"&gt;the problem statement&lt;/a&gt;, how would&lt;i&gt; &lt;b&gt;you&lt;/b&gt;&lt;/i&gt; go about starting it? I&amp;#8217;m assuming &lt;span class="caps"&gt;TDD&lt;/span&gt;, do you make that same assumption? If so, what&amp;#8217;s your first test? Your first few tests? What features do you try to tackle first? What questions do you ask yourself about the problem?&lt;/p&gt;


I&amp;#8217;ve used this problem several times and it&amp;#8217;s a great problem to practice many things including:
	&lt;ul&gt;
	&lt;li&gt;Test Driven Development&lt;/li&gt;
		&lt;li&gt;refactoring (lower case r deliberate &amp;#8211; can you guess why?)&lt;/li&gt;
		&lt;li&gt;Refactoring to Design Patterns&lt;/li&gt;
		&lt;li&gt;Most of the &lt;span class="caps"&gt;SOLID&lt;/span&gt; principles&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Anyway, how would you go about starting this problem? Or better yet, give it a try and post your first few tests (in the order you create them).&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ll be interested in seeing how people start and I&amp;#8217;ll compare it to what I&amp;#8217;ve done (hint, I use this as a class-driven thing, so I&amp;#8217;m pretty flexible on how to start it).&lt;/p&gt;


	&lt;p&gt;p.s. As a result of studying the &lt;a href="http://h10032.www1.hp.com/ctg/Manual/bpia5305.pdf"&gt;manual for my &lt;span class="caps"&gt;HP 32SII&lt;/span&gt;&lt;/a&gt;, I have a much better understanding of just how its stack works. I have a EE and CS background, so the stack implementation makes sense, but I left some of its details out of the problem.&lt;/p&gt;</description>
      <pubDate>Wed, 17 Jun 2009 00:16:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:cd259101-5576-45c4-99b6-866ae4207d25</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>TDD</category>
      <category>randori</category>
      <category>dojo</category>
      <category>okccoco</category>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by iPhone contacts backup</title>
      <description>&lt;p&gt;It is really a good example that most of the programmer should think about this. If we want to do much better for the code. I should understand it. right? You are very good at this and show us good coding idea.&lt;/p&gt;</description>
      <pubDate>Sun, 15 Jan 2012 01:48:23 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:2af9e58d-24d7-4b3c-a6b2-a6beb347a2cb</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-197908</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by anna</title>
      <description>&lt;p&gt;Create the ultimate &lt;a href="http://www.vvme.com/home-theater-projectors" rel="nofollow"&gt;&lt;b&gt;Home Theater Projector&lt;/b&gt;&lt;/a&gt; with a digital projector from InFocus in vvme. Then came the announcement on July 28-the industry&amp;#8217;s first LCD-based 3D &lt;a href="http://www.vvme.com/home-theater-projectors/home-theater-projectors" rel="nofollow"&gt;&lt;b&gt;1080p lcd projector&lt;/b&gt;&lt;/a&gt; was on its way. If you want an LCD projector for your beautiful &lt;a href="http://www.vvme.com/home-theater-projectors/projector-screens" rel="nofollow"&gt;&lt;b&gt;LCD Projector Screen&lt;/b&gt;&lt;/a&gt;, you should take a look at the choices available at Go vvme. Shop and compare InFocus &lt;a href="http://www.vvme.com/home-theater-projectors/conference-projectors" rel="nofollow"&gt;&lt;b&gt;Meeting Room Projector&lt;/b&gt;&lt;/a&gt; and find supplies for your InFocus.&lt;/p&gt;</description>
      <pubDate>Fri, 23 Dec 2011 02:28:28 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:d3b5d535-2034-4d04-9534-80e7ba67f1ba</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-190574</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by Spyder Jackets</title>
      <description>&lt;p&gt;&lt;a href="http://www.spyderjackets-outlet.net" rel="nofollow"&gt;http://www.spyderjackets-outlet.net&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 18 Nov 2011 01:09:48 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:1494a2d6-d2df-46e7-b19d-8588cdab4513</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-175255</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by ysbearing/yisong@1stbearing.com</title>
      <description>&lt;p&gt;Slewing bearing called slewing ring bearings, is a comprehensive load to bear a large bearing, can bear large axial, radial load and overturning moment. &lt;a href="http://www.1stbearing.com" rel="nofollow"&gt;http://www.1stbearing.com&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 19 Oct 2011 02:11:51 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a64040d2-ddaa-4c95-82ec-c57c1a0eaab4</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-159365</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by canada goose coat</title>
      <description>&lt;p&gt;When it comes to feather dress, what appears in your mind? Which kind brand of down jacket do you like prefer? Though there are many down jackets for you to choose from, on the word, which one you really enjoy? I want to say that &lt;a href="http://www.shopcanadagoosejackets.com/cag012-p-12.html" rel="nofollow"&gt;canada goose coats&lt;/a&gt; is really your best choice. I believe you can&amp;#8217;t agree with me any more. When you take the quality into consideration, you will find that it is superior to any other kind of coat. Besides, &lt;a href="http://www.shopcanadagoosejackets.com/" rel="nofollow"&gt;discount canada goose jackets&lt;/a&gt; is a world well-known brand, which has gained high reputation in the world, which has accepted by our customers and some organization. Because of its high quality, some of our loyal customers have promoted it to the people around them. In their opinion, it is good to informing others to know it. Recently, &lt;a href="http://www.shopcanadagoosejackets.com/canada-goose-trillium-parka-c-5.html" rel="nofollow"&gt;Canada Goose Trillium Parka&lt;/a&gt; is on hot sale. What I have to inform you is that all the products there are made by hand, so they are elaborative and elegant enough. It is really beautiful once you dress in. So, if you are a lovely girl or woman, go to the store to buy one for you. You will appreciate it that you have such a coat.In addition, they also have any other products like &lt;a href="http://www.shopcanadagoosejackets.com/canada-goose-gloves-c-6.html" rel="nofollow"&gt;canada goose Gloves&lt;/a&gt; and &lt;a href="http://www.shopcanadagoosejackets.com/canada-goose-snow-mantra-parka-9501m-black-p-9.html" rel="nofollow"&gt;canada goose jacket supplier&lt;/a&gt;.Hope your will like its!&lt;/p&gt;</description>
      <pubDate>Wed, 28 Sep 2011 21:00:28 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:644b757b-8ae5-4339-9e26-91de5a891327</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-147006</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by bagsupplyer</title>
      <description>&lt;p&gt;&lt;a href="http://www.bagsupplyer.com/LV-n634/" rel="nofollow"&gt;Designer replica women LV backpacks free shipping for wholesale&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 07 Sep 2011 05:50:18 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:bbf1c47c-a3d5-4104-a5ee-2e59c165ffa3</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-138085</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by ralph lauren</title>
      <description>&lt;p&gt;I am not significantly into reading, but somehow I obtained to proceed through numerous content material articles on your very own blog. Its remarkable how intriguing it truly is for me to research out you very often.Just proceed through Stephen&#8217;s blog&#8230;&lt;/p&gt;</description>
      <pubDate>Tue, 03 May 2011 01:26:30 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:27c12260-e900-45ff-a0c6-cf5f8d6e504f</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-93963</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by okey oyunu oyna </title>
      <description>&lt;p&gt;nice.&lt;/p&gt;


	&lt;p&gt;internette g&#246;r&#252;nt&#252;l&#252; olarak &lt;a href="http://www.okeyoyunu-oyna.com" rel="nofollow"&gt;okey oyunu oyna&lt;/a&gt;, ger&#231;ek kisilerle tanis,
 turnuva heyecanini yasa.&lt;/p&gt;</description>
      <pubDate>Thu, 28 Apr 2011 14:37:37 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:f3eb1f3e-fca8-4716-87f6-3baa668f4b42</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-92768</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by Solid State Relay</title>
      <description>&lt;p&gt;Classic exposition, I have also mentioned it in my blog article. But it is a pity that almost no friend discussed it with me. I am very happy to see your article.&lt;/p&gt;</description>
      <pubDate>Mon, 28 Feb 2011 23:43:48 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:b2d4ef1a-5f85-451c-84fc-9d53dcda618f</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-67620</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by Free Articles</title>
      <description>&lt;p&gt;&lt;a href="http://www.articlenest.com/Recreation-and-Sport-articles/Hints-for-choosing-the-right-windsurfing-vacation-26000.html" rel="nofollow"&gt;Hints for choosing the right windsurfing vacation&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.articlenest.com/Arts-and-Entertainment-articles/The-importance-of-Mr16-light-bulbs-in-home-35359.html" rel="nofollow"&gt;The importance of Mr16 light bulbs in home&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 01 Feb 2011 21:04:59 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:0f5453d5-666c-4646-a138-d3ce85225331</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-60602</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by http://www.whiteiphone4transformer.com</title>
      <description>&lt;p&gt;The Christmas time is comming, and the most desire present i want to get, is the latest &lt;a href="http://www.whiteiphone4transformer.com" rel="nofollow"&gt;white iphone 4&lt;/a&gt;, can i get one? Tell you after Xmas.&lt;/p&gt;</description>
      <pubDate>Thu, 23 Dec 2010 20:52:10 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:eb768605-b4f9-446b-9065-88d4b90ab0b1</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-51561</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by FLV extractor</title>
      <description>&lt;p&gt;what is  wrong  with me&lt;/p&gt;</description>
      <pubDate>Wed, 07 Apr 2010 03:43:27 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:715a8860-59cd-41ab-a385-49aa4ac7738a</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-9297</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by nike shoes hosting</title>
      <description>&lt;p&gt;Given the time-frame (1968), and the weigh (40 pounds), going with a simpler way to represent expressions was a good idea!&lt;/p&gt;</description>
      <pubDate>Thu, 03 Dec 2009 06:52:46 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:e518ac5b-7193-44e5-99e6-30e0efba24e7</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-5364</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by ?????? ????</title>
      <description>&lt;p&gt;@Test
public void &lt;a href="http://www.soulcast.com/orientalstuff" rel="nofollow"&gt;???&lt;/a&gt;  shouldContainZeroInEachRegisterAfterCreation() throws Exception {
    RpnCalculator calc = new RpnCalculator();
    assertEquals &lt;a href="http://nammal.co.il" rel="nofollow"&gt;??? ??&lt;/a&gt; (BigDecimal.ZERO, calc.getX());
    assertEquals(BigDecimal.ZERO, calc.getY());
    assertEquals(BigDecimal.ZERO, calc.getZ());
    assertEquals(BigDecimal.ZERO, calc.getT());&lt;/p&gt;</description>
      <pubDate>Mon, 13 Jul 2009 08:06:11 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:b10c3a7a-39b0-4b38-9fec-c1a94a6b0b10</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-3705</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by Neal Blomfield</title>
      <description>&lt;p&gt;The core of the problem revolves around manipulating the operand stack.  Looking at the worked examples in the problem definition, the simplest assertion you can make is that when popping an empty stack, the returned value should be 0, so that is where I started from.  
The test is at &lt;a href="http://randomcode.net.nz/2009/06/22/yet-another-bdd-extension-for-xunit/" rel="nofollow"&gt;http://randomcode.net.nz/2009/06/22/yet-another-bdd-extension-for-xunit/&lt;/a&gt; as I used it to drive out a BDD style extension for xUnit.&lt;/p&gt;</description>
      <pubDate>Sun, 21 Jun 2009 18:57:06 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:68bace30-985d-46b4-8159-75d9df99c40d</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-3611</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by Brett L. Schuchert</title>
      <description>&lt;p&gt;&lt;b&gt;&lt;a href="http://www.librador.com/" rel="nofollow"&gt;Martin Vilcans&lt;/a&gt; wrote:
&lt;blockquote&gt;
...isn&#8217;t it funny that HP &amp;#8230;
&lt;/blockquote&gt;&lt;/b&gt;&lt;/p&gt;


	&lt;p&gt;Maybe. It IS easier to build (in circuits or software) for the reason you mention. However, &lt;a href="http://en.wikipedia.org/wiki/Reverse_Polish_notation" rel="nofollow"&gt;RPN has been around since 1920&lt;/a&gt;, so I&amp;#8217;m not sure if their reason was to make something that was easier to build (maybe) or something that is easier to use (well it is for me, but I love vi as well).&lt;/p&gt;


	&lt;p&gt;According to &lt;a href="http://www.hpmuseum.org/rpn.htm" rel="nofollow"&gt;the hp museum site&lt;/a&gt;, they decided on RPN because of its ability to handle more complex expressions. Given the time-frame (1968), and the weigh (40 pounds), going with a simpler way to represent expressions was a good idea!&lt;/p&gt;


	&lt;p&gt;And personally, I have a much better time using RPN than infix calculators.&lt;/p&gt;</description>
      <pubDate>Thu, 18 Jun 2009 02:19:38 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:dbe5a87d-f426-4de0-b3d2-2b68e4eaf09e</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-3586</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by Martin Vilcans</title>
      <description>&lt;p&gt;Sorry for being a little off topic, but isn&amp;#8217;t it funny that HP were able to market RPN as a feature, while it&amp;#8217;s a way to make the calculator&amp;#8217;s design simpler? A typical calculator parses the formula the user enters to create a tree and then executes it on a stack. HP calculators skipped the parsing step and required the user to work directly on the stack. It&amp;#8217;s like RPN is the assembly language of calculators. :-)&lt;/p&gt;</description>
      <pubDate>Thu, 18 Jun 2009 02:06:46 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:12269f22-97b2-45a7-9bad-dc3d533f4ce5</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-3585</link>
    </item>
    <item>
      <title>"Challenge: How would you start this problem?" by Thomas Vidic</title>
      <description>&lt;p&gt;When creating a new class / method, i usually write the simplest test that is possible, so that &amp;#8220;test fails&amp;#8221; means &amp;#8220;does not compile&amp;#8221; and the test passes after some trivial coding. So my first test was something like this:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;public class RpnCalculatorTest {
@Test
public void shouldContainZeroInEachRegisterAfterCreation() throws Exception {
    RpnCalculator calc = new RpnCalculator();
    assertEquals(BigDecimal.ZERO, calc.getX());
    assertEquals(BigDecimal.ZERO, calc.getY());
    assertEquals(BigDecimal.ZERO, calc.getZ());
    assertEquals(BigDecimal.ZERO, calc.getT());
}
}&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Next i tried to get some values into the registers. All the tests first used ints instead of BigDecimal and char, but i refactored later to these types&amp;#8230;&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;@Test
public void shouldContainNumberAfterTakingIt() throws Exception {
    calc.take('1');
    assertEquals(new BigDecimal(1), calc.getX());
}
@Test
public void shouldContainTwoDigitNumberAfterTakingEachDigit()
        throws Exception {
    calc.take('4');
    calc.take('2');
    assertRegisterValues(calc, new BigDecimal(42), BigDecimal.ZERO,
            BigDecimal.ZERO, BigDecimal.ZERO);
}
@Test
public void shouldCopyContentOfXToYIfEnterIsCalled() throws Exception {
    BigDecimal two = new BigDecimal(2);
    calc.take('2');
    calc.enter();
    assertRegisterValues(calc, two, two, BigDecimal.ZERO, BigDecimal.ZERO);
}&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;After that i started with class OperandStack and tests like these:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;@Before
public void setUp() {
    mockStack = mock(java.util.Stack.class);
    stack = new OperandStack(mockStack);
}&lt;/code&gt;&lt;/pre&gt;


	&lt;pre&gt;&lt;code&gt;@Test
public void shouldDelegatePush() throws Exception {
    BigDecimal value = new BigDecimal(1);
    stack.push(value);
    verify(mockStack).push(value);
}&lt;/code&gt;&lt;/pre&gt;


	&lt;pre&gt;&lt;code&gt;@Test
public void shouldDelegatePopIfStackIsNotEmpty() throws Exception {
    when(mockStack.empty()).thenReturn(false);
    stack.pop();
    verify(mockStack).pop();
}&lt;/code&gt;&lt;/pre&gt;


	&lt;pre&gt;&lt;code&gt;@Test
public void shouldPopZeroIfStackIsEmpty() {
    when(mockStack.empty()).thenReturn(true);
    assertEquals(BigDecimal.ZERO, stack.pop());
    verify(mockStack, never()).pop();
}&lt;/code&gt;&lt;/pre&gt;


	&lt;pre&gt;&lt;code&gt;@Test
public void shouldReturnZeroForElementFromTopWithNonExistingIndex() {
    when(mockStack.size()).thenReturn(0);
    assertEquals(BigDecimal.ZERO, stack.elementFromTop(0));
    verify(mockStack, never()).elementAt(1);
}&lt;/code&gt;&lt;/pre&gt;


	&lt;pre&gt;&lt;code&gt;@Test
public void shouldReturnElementFromTopWithExistingIndex() {
    when(mockStack.size()).thenReturn(2);
    when(mockStack.elementAt(0)).thenReturn(new BigDecimal(42));
    assertEquals(new BigDecimal(42), stack.elementFromTop(1));
}&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;These are the first of currently 27 tests beeing now at the point where the second exercise starts.&lt;/p&gt;</description>
      <pubDate>Wed, 17 Jun 2009 15:21:59 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:9da71b81-96a2-43e8-a7aa-fc253202cfa5</guid>
      <link>http://blog.objectmentor.com/articles/2009/06/17/challenge-how-would-you-start-this-problem#comment-3581</link>
    </item>
  </channel>
</rss>

