The Rush 56

Posted by Uncle Bob Fri, 26 Jun 2009 13:40:13 GMT

There’s nothing like the feeling of achievement when you get a complex software system working. It’s the feeling of the hunter making a hard fought kill. By the sheer power of your intellect you have imposed your will upon inanimate nature, and forced it to do your bidding. You feel the rush of power, the satisfaction of victory. You are the master!

That’s the good news.

Shunting Yard Algorithm Kata 61

Posted by Brett Schuchert Thu, 25 Jun 2009 02:36:00 GMT

Next week (end of June 2009) I hoping to schedule the second OkC CoCo Dojo. The first Dojo was fun with a decent turnout. However, it was a bit “loose” (my fault). Loose is fine, but this time around I want to try a different approach and see how that works out.

The problem for this second Dojo is: http://schuchert.wikispaces.com/Katas.ShuntingYardAlgorithm.

Remote Ping-Pong Challenge: Your turn, who's next? (Java) 29

Posted by Brett Schuchert Fri, 19 Jun 2009 06:11:00 GMT

So I want to try a form of TDD using Ping-Pong. Problem is, you are not where I can pair with you directly. So I figured we’d try a slower-form. I’ll post the beginning of a problem. First person to post the next response “wins” – that’s where the next person should pick up from. We’ll continue until the problem is “finished.”

Infinitest for Java, have you tried it? 10

Posted by Brett Schuchert Thu, 18 Jun 2009 16:35:00 GMT

Background

About 2 years ago, I was working with Ben Rady and he demonstrated something he was working on at the time: Infinitest. As often I am, I was a little interested but mostly skeptical – don’t know if that came across or not.

Since then he and others (e.g., Rod Coffin have made amazing strides and created plugins for both Eclipse and IntelliJ.

Taking it for a test run

Earlier this month, I finally decided to give it a test drive. When I made that announcement, Ben made the following (bold?) statement:
For me, using Infinitest is as different from TDD as TDD is from not testing

Challenge: How would you start this problem? 18

Posted by Brett Schuchert Wed, 17 Jun 2009 05:16:00 GMT

On Thursday, we’re holding our first Coding Dojo at the recently opened OkC CoCo. This isn’t the first Coding Dojo to happen in Oklahoma City. Some time back, Dave Nicolette held a Randori with a Fishbowl at the OkC Java User’s Group, and that’s the format I’ll be using for this problem. It was a blast then and I’m hoping it’ll be the same this time around.

Hiding global methods, a C++ example 29

Posted by Brett Schuchert Fri, 12 Jun 2009 15:13:00 GMT

Background

This is a continuation of this discussion. A few of the postings by GBGames have been swallowed so the context is somewhat lost. What follows is an excerpt from an email he sent me and some example C++ code that demonstrates making global methods “testable” in a sense. Or rather, making your code not use global methods during test.

The Offending Method

Here is a method that GBGames has under test:
void SDLHardwareLayer::initializeHardware()
{
    const SDL_version * sdlVersion = SDL_Linked_Version();
    if (sdlVersion->minor < 2 && sdlVersion->major < 2)
    {
        //Error message
    }
    else if (SDL_Init(SDL_INIT_VIDEO |
            SDL_INIT_AUDIO |
            SDL_INIT_NOPARACHUTE) < 0)
    {
        //Error message
    }
    else
    {
        m_screen = SDL_SetVideoMode(m_x, m_y, m_bitDepth, SDL_DOUBLEBUF);
        if (NULL != m_screen)
        {
            SDL_WM_SetCaption(m_title.c_str(), 0);
        }
    }
}

This is how this code is organized:

Another Refactoring Exercise: Design Patterns Recommended!-) 41

Posted by Brett Schuchert Wed, 10 Jun 2009 01:57:00 GMT

Well the previous exercise was fun so here’s another one. The following code is taken from the same problem, an RPN calculator. Originally, the interface of the calculator was “wide”; there was a method for each operator. E.g., plus(), minus(), factorial(). In an effort to fix this, a new method, perform(String operatorName) was added and ultimately the interface was fixed gradually to remove those methods.

Changing he calculator API in this way is an example of applying the open/closed principle. However, the resulting code is just a touch ugly (I made it a little extra ugly just for the hack [sic] of it). This code as written does pass all of my unit tests.

Before the code, however, let me give you a little additional information:
  • I changed the calculator to use BigDecimal instead of int
  • Right now the calculator has three operators, +, – !
  • Eventually, there will be many operators (50 ish)
  • Right now there are only binary and unary operators, however there will be other kinds: ternary, quaternary, and others such as sum the stack and replace just the sum on the stack or calculate the prime factors of the top of the stack so take one value but push many values

So have a look at the following code and then either suggest changes or provide something better. There’s a lot that can be done to this code to make it clearer and make the system easier to extend.

The Perform Method

Slim table examples with fixtures in C# 57

Posted by Brett Schuchert Tue, 09 Jun 2009 04:15:00 GMT

There was not a lot of interest in a series of tutorials. Some, yes, but not very much. So I’m not going to be spending much time right now writing FitNesse.Slim tutorials for C#.

However, I think it’s a good idea to at least have some examples of each of the tables so those few that are so inclined, have something from which to start.

Have a look: C# Slim Examples

Metrics of Moment 64

Posted by Uncle Bob Mon, 08 Jun 2009 16:26:51 GMT

There are two metrics that I think are quite useful in the pursuit of clean code. One is Crap, and the other is The Braithwaite Correlation. The first is a pragmatic call to action, the second is a measure of overall care.

TDDing an Interface - a Twitter influenced discussion 26

Posted by Brett Schuchert Mon, 08 Jun 2009 05:26:00 GMT

Background

I’ve collected a few quick notes regarding TDD and interfaces (as in Java/C# or C++ classes with all pure virtual methods). You dynamic-language-using-types (near irony intentional) can read and laugh to yourselves! You don’t need stinking interfaces, right?

Note, these are based on a few questions from someone I follow on twitter. I considered leaving out the original poster, but since it’s on twitter, I guess that’s not really going to stay hidden. And, quite frankly, his questions are pretty good and quite common.

I’m interested in seeing what other people have to say about this.

Older posts: 1 ... 10 11 12 13 14 ... 38