A Fan Letter to Redline Smalltalk …

January 30th, 2010

crowd

I was inspired by this post by Kent Beck to write a fan letter to Redline Smalltalk, written in the voice of a deliriously satisfied user. This is an excellent way of articulating a vision.

Dear Redline Smalltalk,

I have been using Redline Smalltalk at work and in personal projects for a while now and I just had to let you know what a joy it is to use and how productive I am with it.

My work situation means I have to work on the Java Virtual Machine and I have been looking at alternatives to Java so I could be as productive as possible and stay away from those little Java annoyances and hurdles that slow me down. Having a background in Smalltalk I jumped at the chance to put your Redline Smalltalk through its paces and I have to say I couldn’t tell the difference between your Smalltalk and the others, in fact I think yours was a little faster.

At home I like to use IntelliJ and your plug-in support in the IDE is brilliant, the mix of old style Smalltalk-80 browser, refactoring and file based support is smooth and complete and just what I needed, especially the source level debugging and profiling which I could not live without.  At work we use Eclipse and I can’t tell the difference between the plug-ins so now I’m getting a few other developers to try it, and I think I made some converts.

One developer at work, Steve, keeps banging on about how Ruby On Rails is this and how Ruby On Rails is that, how we need rspec, gem, rake, and how awesome it is to script things and try stuff out with irb. You should have seen his jaw drop when I showed him how I can do all that in Redline and how quickly I could create, test and deploy my Seaside Web App and then push changes to different environments with a simple commit, even while they were running. You really did think of everything to make things complete and integrated with Smalltalk everywhere.

I wondered what you could add in the next release and I just can’t think of anything but if I do, Ill be sure to let you know.

Thanks for a wonderful product that has really changed the way I work and made it fun again.

Regards,

John Q. Geek.

Disenfranchised with Software Craftsmanship?

January 24th, 2010

goodandbad

I consider myself to be a software craftsman as I strive to deliver software that fulfills its purpose, is easy for others to understand and maintain, and is supported by tests but being a craftsman is not required to be successful as a software developer so should you care about being a craftsman?

For a while I have been becoming a little disenfranchised with the notion of software craftsmanship because around me there are some products that make it to market and are successful, even popular, and yet under the covers the code is in my opinion (and probably in the opinion of craftsman) very bad. I have been disenfranchised because around me there are some developers that “appear” to not know or possibly not care about code that is easy for others to understand or maintain or supported by tests, yet they are hired and paid roughly the same as me. Certainly the “gap” between developer and craftsman in pay is negligible. I have been disenfranchised because the majority of companies creating software that I have worked with “appear” solely focused on getting the product out regardless of the underlying implementation, even if the current implementation and practices slow that delivery down, or effect the quality of the resulting product and the cost of maintaining it.

Getting the product out to the customers is a number one priority and I certainly agree with that, I would not change this priority as that isn’t realistic. This reality is why I choose to do things using Agile XP practices. My conundrum about software craftsmanship is not about a Utopian ideal or a desire to stop the world while I make everything shinny and perfect.  I don’t think I am alone in wondering about this situation. My conundrum is both of a personal and a professional nature. Personal in that I wonder if I should I care about learning and improving my skills and professional in that I wonder if I should say or do anything to instill craftsmanship on the projects I am on, especially when craftsmanship isn’t a necessity for success.

The answer or the path to it is intent. What is my intent in wanting craftsmanship? On one level wanting craftsmanship is selfish because I want to work with code that is well crafted and because I have worked hard to be able to produce well crafted code and I want you to do the same. On another level I would like to help others understand what makes well crafted code and the benefits that come from it. While this is still selfish the outcome can benefit more than just me. When working on a project my intent with craftsmanship is to create the most value possible.

I really like to write code and I will always look to improve my skills, it’s a passion that hasn’t wavered for the last 25 years.  When on a project I will be a craftsman and when the needs of the project demand deviation from craftsman like practices then I will put out a quick hack with a clear conscience.  Should I say anything when I see code that could use a little craftsmanship? This depends on what the team consensus is about its practices and if craftsmanship is aligned with the customer’s expectations, after all the Customer and delivery must come first.

Ruby Best Practice Patterns by Kent Beck …

December 23rd, 2009

 bees

I have not written a post for a while as I have been very busy working, developing Redline Smalltalk and looking after my twin boys. Recently I did get some free time and I needed a break from Redline Smalltalk and I picked up a book by Kent Beck from the top of my pile of books to be read. Yes there is a pile and there are about six books in it right now, there is even another Kent Beck book, which should not be a surprise to anyone as Kent is a great mind and his writing is worth your time.

The Kent Beck book I read was “Smalltalk Best Practice Patterns” and while you may think “what the! Isn’t this posts title about Ruby?” what I want to get across is that this book transcends a specific language and is applicable to any Object Oriented language and to anyone wanting to get a good grounding in “Best” practice and patterns of development. Having done Smalltalk, Ruby, Java and C++ I can see how each and every nugget can be applied. So regardless of your language choice you should choose to get this book.

sbpp-book

So what does “Smalltalk Best Practice Patterns” have in it?

SBPP is a quick and easy read and it took me about 16 hours to finish it, but of course I am still thinking about the material in the book and how best to apply it. There are 92 specific items covered and a very good real world example and discussion of why. The real world, every day nature of the book makes it a must have, each section has the following elements:

  • Title
  • Preceding Patterns
  • Problem
  • Forces
  • Solution
  • Discussion
  • Following Patterns

The appendix having a reference to each point making it great to have near by.  The book contains the following sections and topics:

  • Introduction
  • Patterns
  • Behavior
    Methods
    Message
  • State
    Instance Variables
    Temporary Variables
  • Collections
    Classes
    Collection Protocol
    Collection Idioms
  • Classes
  • Formatting
  • Development Example
  • Appendix A:  Quick Reference

Being a big fan of immutable Objects I especially enjoyed the section on “Getting Method”. If you only adopt one thing from this book I hope it is about private getting methods, sometimes called “getters” or “accessors”. It is hard to stress how much better a large amount of software would be if it adopted this practice. This is how Kent puts it:

“Here’s the real secret of writing good Getting Methods - make them private at first. I cannot stress this enough.” and goes on to say “There are cases where you will publish the existence of Getting Methods for use in the outside world. You should make a conscious decision to do this after considering all the alternatives. It is preferable to give an object more responsibility, rather than have it act like a data structure.”

One comment from a reader, Kyle Brown is “The patterns in this book are absolutely fundamental to good Smalltalk programming. No one who calls himself a Smalltalk programmer should be without the knowledge in this book” and I would go so far as to say that no one who calls themselves an Object Oriented developer should be without the knowledge in this book.

MAVEN: Tuning which tests to run …

November 26th, 2009

On a recent project we needed to tune MAVEN to run unit tests and integration tests separately.

When we execute “mvn test” we want just our unit tests to run, and when we execute  “mvn integration-test” we want integration tests to run. Of course the unit tests will run as well because they are a dependency.

This is not as simple as it could be in MAVEN so I’m sharing the working plugin configuration with you.  Here it is:

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*ITest.java</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${integration.test.skip}</skip>
<includes>
<include>**/*ITest.java</include>
</includes>
<excludes>
<!– Ensure Maven inhierits exclude –>
<exclude>must-be-here-for-maven</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

A new blog commenting on East

October 9th, 2009

Gregor Gramlich presents his view on East here.

More East …

October 1st, 2009

 compass2

Recently I found that my East paper was blogged about elsewhere and of course I’m flattered. So I dug around a bit and found some comments suggesting that the code in the examples was not very readable, and while I find that debatable I think it is important to give a simpler example, one that is as simple as I can make it, along with another revision of the principles/rules of East Oriented code.

Principles/Rules:

  1. All public methods should be void, boolean or return a reference to the current object (this in Java).
  2. Objects that implement the Factory or Builder pattern or similar are an exception.
  3. East is better suited to composite objects, not primitive objects. Personally I don’t make this distinction.

An Example:

Imagine we have a Customer class and we want to send a present to the Customer on their birthday, flowers for a girl and cufflinks for a boy. In a typical non-East and very non-Object Oriented way (in my opinion) your object could look like this:

class NotOOCustomer {

  public Sex getSex() {}

  public Date getDateOfBirth() {}

}

Now we change it to be East and Object Oriented:

class EastOOCustomer {

  public boolean isMale() {}

  public boolean isBirthday(Date today) {}

}

I’m hoping that this example is simple and readable?

Now if you try writing the code to send the flowers or the cufflinks using first the NotOOCustomer class and then the EastOOCustomer class you will see a big difference between the two. When done, change the internal representation of gender and the date of birth in each version and see the impact on your code. For the full experience and magic try to use Test Driven Development.

What should happen is this:

  1. You wrote less code using the East Object Oriented Customer class.
  2. You had a smaller change impact when changing the internal representation of gender and date of birth.

I’m keen to hear your feedback and see your examples for both cases. Please drop me a line.

Clean Code: an example …

September 27th, 2009

A friend asked me to review some of the code in his codebase and discuss what if anything I would change to make the code cleaner.

For me the term “Clean” code means all those things outlined in the book “Clean Code” by Robert C. Martin, especially principles like the Single Responsibility Principle, the East / Tell Don’t Ask Principle and the practice of keeping things DRY (Don’t Repeat Yourself) and others. One thing I think is important but not made that clear in various texts is the benefit of keeping the “what” of Business intent clear and uncluttered from the “how” of the implementation. What follows is an example and how it was refactored to be more clean.

My friend has a class that looks through a database of Users to notify them when their Book subscriptions are about to expire. Not all the Users want to be notified when this happens. The typical implementation that I saw was a single class that gets the users, iterates through them and dispatches an email to each User that wants to be notified.

A1 public void notifyExpiredUsers() {
A2   Date date = new Date();
A3   List<User> users = getUsers();
A4   for (User user : users) {
A5     if (date > user.getExpiryDate() && user.getEmailNotification()) {
A6       sendEmailTo(user.getName(), user.getEmailAddress());
A7     }
A8   }
A9 }

We then discussed what I would like to change and why …

The first thing I would like to do is clean this method up to express the intent more clearly, with each method having a single responsibility.

B1 public void notifyUsersWhoseBookSubscriptionsHaveExpired() {
B2   List<User> bookSubscribers = getBookSubscribers();
B3   for (User bookSubscriber : bookSubscribers) {
B4     notifyUserWhoseBookSubscriptionHasExpired(bookSubscriber)
B5   }
B6 }

C1 public void notifyUserWhoseBookSubscriptionHasExpired(User bookSubscriber) {
C5   if (hasBookSubscriptionExpired(bookSubscriber)) {
C6     sendSubscriptionExpiryNotificationTo(bookSubscriberNotificationDetails(bookSubscriber));
C7   }
C9 }

* note that the method in #C6 bookSubscriberNotificationDetails() returns a new object BookSubscriberNotificationDetails.

D1 public boolean hasBookSubscriptionExpired(User bookSubscriber) {
D2   Date today = new Date();
D2   return (date > bookSubscriber.getSubscriptionExpiryDate() && bookSubscriber.getEmailNotification());
D3 }

To me the code is looking a lot better already as we have:

1. Used a name that represents the business WHAT, a “bookSubscriber” rather than the HOW, a “User”.
2. Removed several responsibilities of the first “notifyExpiredUsers()” method into separate methods with single responsibilities.
3. Replaced a combination of conditions in the if() statement (A5) with a call to a method that describes the Business intent (C5) rather than the mechanism used to find out how.
4. Introduced a new class BookSubscriberNotificationDetails in C6 to capture the binding between the notification process and where in the model the information comes from.
5. Replaced the call to send an Email in C6 with a call to a method that describes the intent rather than the how.

There is still a problem with C5 which it has carried on from A5 and that is the combination of conditions that make the code less clear. The combination of a book subscription expiring and the subscriber wanting to be notified should be exposed through the naming of the method. So lets change that.

E1 public void notifyUserWhoseBookSubscriptionHasExpired(User bookSubscriber) {
E5   if (shouldNotifyThatBookSubscriptionHasExpired(bookSubscriber)) {
E6     sendSubscriptionExpiryNotificationTo(bookSubscriberNotificationDetails(bookSubscriber));
E7   }
E9 }

F1 public boolean shouldNotifyThatBookSubscriptionHasExpired(User bookSubscriber) {
F2   return (hasBookSubscriptionExpired(bookSubscriber) && bookSubscriberWantsNotification(bookSubscriber));
F3 }
F4
F5 public boolean bookSubscriberWantsNotification(User bookSubscriber) {
F6   return bookSubscriber.getEmailNotification();
F7 }

While this is an improvement because the business intent of the code is more clear, there are still some changes we can make to the code to further to minimize change impact by hiding data and moving behavior close to the owner of the associated data.  This is in line with East Principles. The first change to go East will be with D2 where the bookSubscribers subscription expiry date is exposed to the caller (travels West).  Also exposed is the email notification value, so lets change them.

G1 public boolean hasBookSubscriptionExpired(User bookSubscriber) {
G2   Date today = new Date();
G3   return bookSubscriber.isSubscriptionExpiryDateBefore(today);
G4 }
G5
G6 public boolean bookSubscriberWantsNotification(User bookSubscriber) {
G7   return bookSubscriber.isEmailNotificationRequested();
G8 }

The code in G3 and G7 changed slightly to not expose values from the bookSubscriber and the remifications of this are subtle but far reaching. They are:

1. We have captured in one place the Business fact that we care about subscription expiry dates that are before other dates. At this stage we don’t have an isSubscriptionExpiryDateAfter(date), so we can tell the Business does not yet do things after an expiry. Looking through the codebase for usages of “<” or “>” would much harder.
2. We have turned a simple get of a boolean value into a descriptive Business reason for its existance.

A lot of the above modification may just appear superficial with splitting methods up or using different names and to some degree that is true but what should be more clear is the Business WHAT and not the implementation HOW. Keeping the Business WHAT clear and uncluttered from the implementation HOW is part of what Clean code is to me. We should be able to modify the implementation HOW quite significantly without effecting the Business WHAT.

Personally I would go further and make a BookSubscribers class that represents the behviour that is related to a collection of BookSubscribers. I would do it because the Business talks about Book Subscribers so this concept should make it into the domain model, and I would do it because the operations on groups of Subscribers belongs in one place and not spread around between helper classes or the methods of other unrelated classes. However, this is another post waiting to happen soon.

So is the result cleaner and more clear, please let me know what you think.

switch() blade …

September 26th, 2009

switchblade

 As some of you may be aware I am currently writing a Compiler for Smalltalk that will output JVM bytecode. The compiler is in Java and as part of that compiler I have a large switch() statement which is very long (600+ lines) and in my opinion ugly and not OO.  When I mentioned to a friend how the switch statement offended my sensibilities they replied “but it’s part of the language, so why not use it.” and it got me thinking about when to use it, when not to use it and more importantly how to write code that achieves the same result as a switch() but in a clean, readable, DRY way.

Two things I would like to make clear are that 1) the switch statement has a place but 2) it is not OO and in most every case it can and probably should be avoided.

When you need logic executed based on some facet/attribute of an object then the switch and the alternative approaches outlined can be applied.

To work though the pro’s and con’s and to show alternative approaches to a switch() we need to have an example to work through, so imagine we have to code a machine that prepares fruit. This machine takes a hopper of different fruits and depending on what fruit it is, slices, peels, juices it or a combination of these and puts the result in an output hopper. We are also working in Java which is a key point since other languages make it easier to avoid the switch() statement because they don’t have type erasure which happens when putting classes in a collection of a common base type. ie: when you take them out of the collection they have lost their type so you cant call overloaded methods with them.

Simplified, the core function of the machine might typically look like this with a switch statement:

handleFruit(List<Fruit> inputFruitHopper, List<Fruit> outputHopper) {
  this.outputHopper = outputHopper;
  for (Fruit fruit : inputFruitHopper)
    handleFruit(fruit);
}

handleFruit(Fruit fruit) {
  switch (fruit.type()) {
    case APPLE: ...
    case BANANA: ...
    case PEAR: ...
    case GRAPE: ...
    case ORANGE: ..
    default:
      throw whatFruitIsThisException();
    }
}

To me the problems with this approach are:

1) The handler has to have knowledge about some part of the Fruit in order to dispatch to the appropriate handling. This binds the dispatcher to the fruit which may seem like no big deal but:
1.1) it limits the ability to have a design that is more dynamic and that doesn’t have to change when new types of Fruit are added. ie: to support Kiwifruit you have to change the handleFruit(Fruit) method.
1.2) it locks in the mechanism for defining types of fruit (fruit.type()). We could use something else like the Class or a name as the switcher but the net effect is the same. 1.3) it exposes internals of fruit which voids information hiding, a principle of OO.
1.4) the tests for this method will be very large especially if they are to cover each case and the default case.
1.5) the possibility of reuse of this handler is very low, therefore you may have to write and test other dispatchers again and again. ie: if you had to weigh each fruit in a hopper would you want to code the same switch statement again?
1.6) switch() statements have a habbit of growing very large.
1.7) possibly the worst thing about this approach is that the logic for handling each type of Fruit is here within the handler who’s single responsibility (SRP) should be just the dispatching.

To me the benefits of this approach are:

1.8) It is said to be performant but I have not yet tested the performance of this approach over the others that can be used.
1.9) Im stuck on thinking of any other benefit.

There are alternatives to using a switch() which is what this post is all about and time permitting I’ll explore each of them at least briefly.

2) Use a Command Dispatch Pattern

The command pattern approach is where a hashtable of “command” objects is kept keyed on the Class of the expected objects. With this approach the handleFruit(Fruit) method could look like this:

handleFruit(Fruit fruit) {
  FruitCommand fruitCommand = getHandlerFor(fruit.getClass());
  if (fruitCommand == null)
    throw whatFruitIsThisException();
  fruitCommand.executeWith(fruit, outputHopper);
}

To me the benefits of this approach are:

2.1 The handler is short and easy to understand an test.
2.2 The handler doesn’t have to change to handle new types of Fruit.
2.3 The handler has a single responsibility, that of dispatching the Fruit to the appropriate command.
2.4 The logic to be applied to each fruit (slicing, peeling, juicing) is not part of the handler. This means new logic can be added without changing the handler.
2.5 While we use the Class of fruit to determine the command to be applied, we don’t expose the internals of the Fruit. There is a subtle difference between using a mechanism of the language and what we define as state/properties of a model. I see the former as less evil.
2.6 The testing of dispatcher and of each command is separated and therefore simpler.
2.7 This dispatcher could be generified with Java generics to be reused in other parts of the code.

To me the problems with this approach are:

2.8 The type of Fruit is still unknown to the command which will be required to ‘cast’ the Fruit to a subtype. ie: FruitCommand.executeWith(Fruit fruit, List<Fruit> outputHopper)
2.9 The switch statement did the dispatching and the registration of what logic (command) applies to what Fruit. In the command pattern approach this needs to be somewhere else, typically in an initialization mechanism, be it code or an IOC container.
2.10 It appears it would be less performant than a switch but I have not tested this.
2.11 As mentioned in 2.5 we use the Class of the object to lookup the command requiring each different Fruit to be a subtype. Personally I think they should be anyway - this is OO.

3) Use a Double Dispatch

This approach is where the object that is used to determine the logic to be applied is asked to call back on the dispatcher. This is how it might look:

handleFruit(Fruit fruit) {
  fruit.callback(this);
}

To me the benefits of this approach are:

3.1) The handler is very simple.
3.2) The callback can be to a method on the dispatcher or a subclass of it that accepts the specific Fruit subtype. ie:  the handler would have methods like: handle(Apple apple) So the logic gets the expected type without a cast.
3.3) It appears it would be faster than the Command Dispatch Pattern, but I have not tested this.
3.4) Code wise it is ‘neater’ then a large switch().

To me the problems with this approach are:

3.5 This is a very similar approach to the switch statement and would require changing the handler to
cater for new Fruit types.
3.6 The other negatives with the switch apply here as well, except for some of the testing concerns since each handler method can be tested independently of the rest of the dispatch logic.
3.7 There is now a direct binding between the Fruit and the dispatcher so it can make a callback. This can be made more subtle in a wrapper or subclass.

Conclusion

I have presented two alternatives to using a switch() statement and there are probably others. The key point I’m trying to make is that just because a language has a feature doesnt make it right to use it without consideration. What makes an approach “right” is a balance between readability, lowering duplication in code and effort, cost to change and lastly performance.

For my Smalltalk parser I still have a switch statement right now and after I have done some performance testing on the alternatives above and possibly others I will make a choice between the approaches, most likely favoring readability and simplicity. Which of the approaches is readable and simple to me may vary greatly to you which, makes for interesting conversations, but please don’t use a switch as a no thought default.

SmalltalkJVM: From dream to …

August 23rd, 2009

 stduke*

My Smalltalk for the Java Virtual Machine is progressing and while I’m not in the home stretch yet I can see the turn that leads to that stretch ! When I reach that turn I’ll open up the github account for people to download the project.

So what is this Smalltalk for the JVM going to do:

  1. Provide a Smalltalk-80 implementation that compiles to bytecode
  2. Provide a command line interactive environment like IRB or Lisp REPL
  3. Provide debug support (breakpoints etc)
  4. Provide generators for converting Smalltalk-80 to other languages, like Ruby, Python and Javascript, and to target other VM’s like LLVM and Parrot.
  5. Provide build tools and libraries to get things done (like rspec, rake, roodi, stunit etc).
  6. Provide a port/implementation of Seaside !
  7. Provide tools for bundling your code for deployment to J2EE containers.

If you would like to know more then please drop me a line or follow smalltalkjvm on twitter.

*This image which I’m calling Saint Duke (ST Duke) was done by Tim Cuthbertson, who is not only a talented developer, but a juggler and a 3D artist.

TDD: Where to start ?

August 8th, 2009

birds-eye *

When I do Test Driven Development and I have the choice of doing it how I like then I start from the Top-Down. I choose Top-Down because it keeps me focused on the goal and what the Business/User wants. With Top-Down I go down fewer rabbit holes looking for an elusive bug or wrestling with a tricky implementation.

I start by writing down what it is I am building and what tests must pass before I accept the work as done. For example, I am working on a Smalltalk compiler for the Java Virtual Machine and one of the deliverables is the compiler, so this is how I started the acceptance tests:

The compiler will be done when …

  • Compiling Statements made up of a single Expression
  • Compiling Methods with a Message Pattern followed by Statements

I try to write all the criteria down before starting any implementation. I do this so I can prioritize and see the scope of what I am doing. I then convert these sentences into the syntax of the language I am developing in, sometimes this makes the test method names more uniform but I try not to loose important information:

compilingStatementsWithAnExpression()
compilingMethodsWithMessagePatternAndTemporariesAndStatements()

The next and probably most important step is writing the line of code that will prove or disprove that the criteria has been met. I write this before any implementation. If I can’t form a hypothesis in code before writing implementation code then I’m usually not sure of what I am doing and I should step back and become sure with a spike. I follow the same process of writing the verification or assert statement in English and converting it to the target language.  Here are the verification steps for the above tests, assuming the use of the Java Mockito Testing framework (in my case the compiler is done when it can call the code generator with a valid abstract syntax tree):

verify(generate).receive(statementWith(expression()))
verify(generate).receive(methodWith(messagePattern(), temporaries(), statements()))

I use the features of the language or the testing framework to facilitate code that is descriptive, even if this means a little more work since the test also serves as documentation. In my case I can tick off each test against the Smalltalk grammar shown in the back of the book Smalltalk-80: The Language and its Implementation.

When I have all the tests ready I sometimes comment out all but the one I want to implement first and make a start on implementing it.  Commenting out the others means I won’t get swamped and disheartened by a flood of red-bars (failing tests). As I implement each test I leave it uncommented and move onto the next test. Eventually all the code is uncommented and passing (green-bar).

The test I implement first is driven by the Business as it is typically the feature they want first or the one that shows them or me the most important information to make decisions on moving forward.

When implementing I fake-it-until-i-make it, that is, I hard code the results output from the code under test to ensure the test passes, then I go back an remove the hard coding and implement the real logic. I do this because it provides an opportunity to see more of the requirements to get the test to pass and an opportunity to see the test is correct. There have been a few times when the test was incorrect and passing and therefore the code was not correct and I was none the wiser.  Not happy times.  While using fakes I output a message to let me know a fake is in use, so I remember to remove them all.

The above approach is the one that works best for me and I suggest you try it as I find it yields less code overall.

ADDENDUM:

I received some feedback that suggested I may not be following the failing-test-implement-pass-refactor’ cycle and the approach I use does, as I start with a test that fails because I have not yet faked it. I then implement the fake and the test passes. I then continue to fake more tests to show two important things, 1. The tests work and, 2. The commonality in tests and the potential implementation. At some point in the process I will have no fake code at all and the actual implementation will have been done after a failing test. I have seen the false-positives scenario too many times so I stop and test the test just a little more. YMMV

*  The image used here is by Cannboys and you can see his portfolio here: http://www.istockphoto.com/cannboys