Code, JavaEE, Technical

TDD Code Design – Registration User Story

I really like Test Driven Development.  Unfortunately, many times it has been test-last development; write the code that does something useful and then write a unit test. That is a noble effort, however, one is missing out on the beauty that comes from making a test that fails and in the process of making it pass, see the emerging design for a new module, function or feature.

For example, consider the following:

User Story
As a guest of IL website, I want to register in order to access its features.

How would you start?  Do you simply create a class hierarchy with all the bells and whistles?

I would start simple with a test case (using JUnit).


public class RegistrationTest {

private RegistrationInterface registrationService;


public void testGuestRegistration() {

Response response = registrationService.register(user);



public void setUp() {

registrationService = new RegistrationService();




Basically, the signature of the register method says this is what I expect the

Api to provide, i.e., this is an example of how-to use what has yet to be written.

Note, there may be other interactions and collaborations that need to happen

when creating a user in our fictitious application, but none of those things have

been pre-defined, they will be discovered as I continue the TDD route, this makes

design fun and exciting!






Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s