<?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: Tag pong</title>
    <link>http://blog.objectmentor.com/articles/tag/pong</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Remote Ping-Pong Challenge: Your turn, who's next? (Java)</title>
      <description>&lt;p&gt;So I want to try a form of &lt;span class="caps"&gt;TDD&lt;/span&gt; using Ping-Pong. Problem is, you are not where I can pair with you directly. So I figured we&amp;#8217;d try a slower-form. I&amp;#8217;ll post the beginning of a problem. First person to post the next response &amp;#8220;wins&amp;#8221; &amp;#8211; that&amp;#8217;s where the next person should pick up from. We&amp;#8217;ll continue until the problem is &amp;#8220;finished.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;Interested? First the ground rules, then the problem and the starting code. This is Java. However, if someone responds in another language, that&amp;#8217;s cool. I might try and follow up, but you&amp;#8217;re welcome to do so yourself. I can imagine having multiple threads going on at the same time. (If you&amp;#8217;d like your own language thread, ask and I&amp;#8217;ll post another blog entry for that particular language.)&lt;/p&gt;


&lt;h2&gt;Ground Rules&lt;/h2&gt;

	&lt;ul&gt;
	&lt;li&gt;Follow the three rules of &lt;span class="caps"&gt;TDD&lt;/span&gt; + Refactoring.&lt;/li&gt;
		&lt;li&gt;Fix the one failing test.&lt;/li&gt;
		&lt;li&gt;Add one to three more tests before posting.&lt;/li&gt;
		&lt;li&gt;Make sure you leave one and only one failing test for the next person to fix. (Meaning you can add two passing tests but leave a third test failing, or you can just add one failing test).&lt;/li&gt;
		&lt;li&gt;You can/should refactor the test code and the production code&lt;/li&gt;
		&lt;li&gt;If you feel a test is wrong, you may change it, but be prepared to justify it.&lt;/li&gt;
		&lt;li&gt;I&amp;#8217;ll serve as the customer, so I get to define what is &amp;#8220;correct&amp;#8221; &amp;#8211; however, I can be argued with and I can lose arguments (see some of my other blog postings for evidence).&lt;/li&gt;
		&lt;li&gt;Feel free to respond with comments/suggestions rather than additional tests.&lt;/li&gt;
		&lt;li&gt;Feel free to apply refactorings like extract method, rename, split loop, ... Keep the code clean!&lt;/li&gt;
	&lt;/ul&gt;


&lt;h2&gt;The Problem&lt;/h2&gt;
Translate infix notation to postfix notation. Consider reviewing &lt;a href="http://en.wikipedia.org/wiki/Shunting_yard_algorithm"&gt;The Shunting Yard Algorithm&lt;/a&gt;. But that&amp;#8217;s a guideline.&lt;p/&gt;

&lt;h2&gt;The Start&lt;/h2&gt;
Here is the test and production code. Note, when you respond, surround your code with one of the following pairs of &lt;span class="caps"&gt;HTML&lt;/span&gt; tags:

	&lt;ul&gt;
	&lt;li&gt;&amp;lt;typo:code&amp;gt;, and &amp;lt;/typo:code&amp;gt;&lt;/li&gt;
		&lt;li&gt;&amp;lt;pre&amp;gt;, and &amp;lt;/pre&amp;gt;&lt;/li&gt;
	&lt;/ul&gt;


&lt;h3&gt;InfixToPostfixConverterTest&lt;/h3&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_Java "&gt;package com.om.example;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.Collection;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
public class InfixToPostfixConverterTest {
   private final String infix;
   private final String expectedPostfix;

   @Parameters
   public static Collection&amp;lt;String[]&amp;gt; data() {
      ArrayList&amp;lt;String[]&amp;gt; values = new ArrayList&amp;lt;String[]&amp;gt;();

      addTestCase(values, null, &amp;quot;&amp;quot;);
      addTestCase(values, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);
      addTestCase(values, &amp;quot;45&amp;quot;, &amp;quot;45&amp;quot;);
      addTestCase(values, &amp;quot;+&amp;quot;, &amp;quot;+&amp;quot;);
      addTestCase(values, &amp;quot;3 + 8&amp;quot;, &amp;quot;3 8 +&amp;quot;);

      return values;
   }

   private static void addTestCase(ArrayList&amp;lt;String[]&amp;gt; values, String infix,
         String expectedPostfix) {
      values.add(new String[] { infix, expectedPostfix });
   }

   public InfixToPostfixConverterTest(String infix, String expectedPostfix) {
      this.infix = infix;
      this.expectedPostfix = expectedPostfix;
   }

   @Test
   public void checkTranslation() {
      InfixToPostfixConverter converter = new InfixToPostfixConverter();
      String result = converter.translate(infix);

      assertEquals(expectedPostfix, result);
   }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;InfixToPostfixConverter&lt;/h3&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;package com.om.example;

public class InfixToPostfixConverter {
   public String translate(String string) {
      if(null == string)
         return &amp;quot;&amp;quot;;

      return string;
   }
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
      <pubDate>Fri, 19 Jun 2009 01:11:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:8b0dd6cc-9121-43aa-be27-dd0c502402cf</guid>
      <author>Brett Schuchert</author>
      <link>http://blog.objectmentor.com/articles/2009/06/19/remote-ping-pong-challenge-your-turn-whos-next-java</link>
      <category>Schuchert's Scattered Synapses </category>
      <category>ping</category>
      <category>pong</category>
      <category>pairing</category>
      <category>remote</category>
      <category>TDD</category>
    </item>
  </channel>
</rss>

