Using Value Objects in Fitnesse With Nested Tables

December 3rd, 2006 by James Carr

Today I discovered something rather cool while playing with FitLibrary. Not only can you just pass primitive types to fixtures, you can also pass in value objects as well (at least in DoFixture) by using nested tables.

Nested tables work pretty interesting, and I couldn’t really find much documentation on it outside of a scant bit on the fitnesse mailing list and what I was able to figure out by fiddling around. To start things off, I thought I’d show off an example I have while putting together an Email Fixture for checking emails in a mail box. In this particular case, this is a portion that sends an email for the fit test for the fixture. Below is what the table with the nested table looks like:

To do this, you have to assign the nested table to a variable, then simply reference the variable within the table.


!define inner_table (|subject|This is a test|
|type|text/plain|
|body|some content|
)

|Email Accessor|
|connect to|*****|using password|test123|on server|example.com|
|check for|0|messages with subject|This is a test|
|send email|${inner_table}|
|disconnect|

The code for the EmailAccessor is simple… simply extend a DoFixture and have a method called sendEmail which takes an argument (in our case, of type EmailMessage):


public class EmailAccessor extends DoFixture{
   ...
   public void sendEmail(EmailMessage message){
      this.box.send(message);
   }

Now, how does the inner table map to the domain object it represents? The values in the first column map to setters, with the values in the second or further columns as parameters. Below is the relevant method signatures for EmailMessage:


public class EmailMessage{
	...
	public void setType(String type){
	...
	}
	public void setSubject(String subject){
	...
	}
	public void setBody(String body){
	...
	}
}

You can even use nested tables within nested tables to map to domain objets for arguments to other domain objects, although it may look a bit complicated at that point. It worked well on a personal project I did some time ago however as the documentation for a standard I was implementing contained a set of nested tables that outlined the message format. ;)

OOPSLA 2006: Design Fest Round 2

November 4th, 2006 by James Carr

As I mentioned earlier, I had attended the day long DesignFest session at OOPSLA my first day there. Since the whole experience picqued my interest, I decided to go ahead and attend a second session on Tuesday afternoon in an effort to perhaps inject myself more, and give it another shot.

I spotted Eric Evans sitting at one of the tables, so I decided to join them in hopes to get to see Eric tackle whatever design problem that was given, but unforunately he was only a moderator so he couldn’t participate much. :(

At first, things started a little shaky as they had at the previous DesignFest, although (thankfully) we all agreed on certain ground rules at the start, such as not being concearned about performance and such. There was quite a bit of debate on certain designs at first, and Eric even commented a bit that he felt like it was “maddening” because he couldn’t jump in and start working on the design with us. ;)

However, as time passed, we tended to find lots of common ground in our design, and suddenly everything began to mesh together in the design and it began to rapidly surface. We began quickly sketching out various sequence diagrams to show the object interactions that completed different user stories, and very interesting designs began to emerge.

The session wasn’t as long as the first one I attended, only being half a day (I believe the duration was possibly 3 hours or so). The interesting aspect was that despite the short amount of time, we actually accomplished quite a bit more than the team I was on did the first day.

Not to say anything bad of the team members of the previous team I was on, it really just boiled down to team cohesiveness. Although we were a little disjointed at first (as to be expected with a group that doesn’t know each other), as soon as we all broke the ice a bit, things began to run a bit more smoothly.

Another insight I gained from this is just about every group has “The Leader”, someone who tends to dominate the discussion at first and kind of drive the team. However, although we did have a “leader” at first, the role kind of melted away with many of us taking turns with the role, and sometimes even seeing it disappear entirely. The result was we were able to collaborate quicker and easier.

Definately a great experience.

OOPSLA Day 1: DesignFest

October 28th, 2006 by James Carr

I took part in DesignFest my first day at OOPSLA, and it was much fun and very interesting seeing all of the subtle dynamics that were at work. One of the major ideas that I gleaned from the experience was this: a good design can only come about from how well the people involved can work together.

On the first day, I attended the day long session, and were given an interesting problem to whip up a design for. Right away I noticed that practically all of us were really not on the same page in how we tackle a problem, and throughout the day we were very disjointed and unfortunately I decided to ind of withdraw and rather than participate much, decided to just observe. Through this, I was really able to observe some of the flaws that lead to bad design.

  1. Team Cohesiveness. The most contributing factor to the failure of my teams design is that we had very little cohesiveness. From the start we were in almost complete disagreement, and almost all of us were from radically opposing design concepts. This is the major flaw that broke our design, because how well can we design if we can’t agree?
  2. Concern With Pre-optimization. The second factor was that my team was concearned with pre-optimization. When the “customer” came around asking if we had any questions, the first question was “how many ratings can a user enter”, to which the reply was somewhere around 10,000 (a high number aimed to be a pothole no doubt). ;) This led the team to go with a database centric design rather than focusing on the model of the domain problem, and leads to another factor I saw as a contributor to bad design.
  3. Database Driven Design. The fact of the matter is that when it came to designing the system, the team began designing the database tables first. This leads to a design that is heavily reliant on the database and that is driven by the database. Rather than Entities with behavior interacting with other entities in the domain, we were instead left with shallow objects that passed around references to database ids and heavily reliant on the underlying implementation. One interesting thing I noticed from this is that when the “customer” returned, developer interaction with the customer contained database related words like “inserting ratings”, “triggers”, etc.
  4. Design Contained Too Much Technical Details. This is somewhat related to the previous factor, but also considers the fact that the design contained a lot of technical implementation details up front, which kind of felt “meshed in” with the model without a clear separation of concerns. It’s my belief that if we had began coding the design, we would have seen a system with domain logic in the UI, or UI related details in the model, and database related code seeping through both.
  5. Big Batch Design Attempt. Lastly, the user stories (which were included and very nice if I may point out) were largely ignored… rather than tackling one at a time, all of the ideas and technical details behind them were attempted all at once, which made things even more chaotic. Another thing I noticed was that due to the User Stories only being used as hints to requirements, more requirements were actually added by developers, even ideas of a full security subsystem (not really specified).

The result was that we never really got past the first user story and what we did have was a largely chaotic, coupled, and incomplete mess. ;)

The main contributing factor was that we never were able to come to agreement, and near the end there were even a few of us working on separate designs. The fact of the matter is that team interaction, communication, and the focus on people over processes is what can really make or break a project, and it doesn’t matter how good the developers are.

On a final note, I was impressed with the problems given at DesignFest. They were sprinkled with requirements that could be simple or VERY complex depending on how you viewed them, they had an on hand person playing the customer to interact, clarify requirements, and answer questions (but wandering around, and you needed to grab them to come over if you wanted to work with them). Another interesting aspect is that there was a bit of an agile focus, as the customer showed up and added/changed requirements at the last minute, as a test to see how flexible your design was. I was equally happy that they had clear and concise user stories, and if we had followed an iterative model, we could have quickly implemented each story one at a time.

I really wished I had brought my laptop, as I think it would have been interesting to setup fitnesse tests for each of the user stories. ;)