Category Archives: Kata

WordFinder Kata

This is a continuation of Code Kata == Practice; I left off with two tests for my fake customer request; one test is passing and the other isn’t.  Going forward I had decided to create a new class WordFinder which is responsible for finding all of the words in the provided string. For definition purposes a word is text that is separated from other words by spaces.

It starts with a single test.

@Test
	public void testFindWords() {
		String seed = "I am a programmer";
		String[] expectedWords = { "I", "am", "a", "programmer" };
		int expectedNumberOfWords = expectedWords.length;
		WordFinder finder = new WordFinder();
		String[] foundWords = finder.findWords(seed);
		assertEquals(expectedNumberOfWords, foundWords.length);
		assertEquals(expectedWords[0], foundWords[0]);
		assertEquals(expectedWords[1], foundWords[1]);
		assertEquals(expectedWords[2], foundWords[2]);
		assertEquals(expectedWords[3], foundWords[3]);
	}

and then an implementation:

public String[] findWords(String seed) {
		String[] foundWords = seed.split(SINGLE_SPACE);
		return foundWords;
	}


Code Kata == Practice (to me at least)

I have been reading some about Code Katas and what I take from it is that to be a professional and great programmer, I have to practice.   This seems pretty obvious, but I think I take things for granted and get comfortable with the norm and the way things are going.  This really struck me tonight.  I asked myself if I really understood Object Oriented Design principles, and the answer was I still have a lot to learn.   As Uncle Bob, of Object Mentor, has said, “All too often today’s programmers are unaware of the principles that are the foundation of the disciplines that their languages were derived around.”  I find myself in this category, so I decided to practice.

Continue reading


Follow

Get every new post delivered to your Inbox.

Join 59 other followers