May 10

Over the past week, I’ve had some time to dig into the new ASP.NET MVC framework. For starters, my background in web development is mostly classic ASP talking to COM objects built in C++. I’ve only used ASP.NET to provide web services for smart clients. Beyond that, my experience has been all PHP joined by a short experimentation period with Ruby on Rails. When Scott Gu presented the new ASP.NET MVC framework at the first ALT.NET Austin in 2007, I was excited to see Microsoft stepping into the space where at the time Monorail was the only viable choice.

First things first — the benefit of waiting until now to jump into ASP.NET MVC is being able to learn from the writing that has been produced. Jimmy Bogard has written a number of articles about how they are using the MVC framework, including strong opinions about how to adhere to the SOLID principles and ensure the long-term maintainability of the final application. Jeremy Miller and Chad Myers have certainly voiced their opinions about the framework, resulting in their own FubuMVC framework.

From my initial dive into the framework, it seems as if an emphasis was put on the View and Controller while leaving the Model a bit behind. Views and controllers are certainly easier to demonstrate, but a good model is going to be very domain specific and hard to generalize in a demo. The framework does make it easy to keep the domain and application services separate from both the controllers and the views, so I think the underpinnings for success are certainly present.

At this point, I’ve only been working with ASP.NET MVC for about a week and I am enthusiastic about what is being provided by Microsoft. Considering Microsoft’s efforts to work with the development community during the development of the framework combined with developer interest, I think it is a sensible solution and certainly a better alternative to ASP.NET WebForms in a .NET development shop. Plus, I feel that web developers should know both HTML and JavaScript, they are the languages of the web after all.

Jan 16

MassTransit supports sagas, which are long-lived transactions consisting of multiple events. The saga support makes it easy to orchestrate the events into a process, but it doesn’t do much to help with state management. Since state management is fairly common, I felt it necessary to add some support for a state machine.

In MassTransit, a saga is defined by creating a class and attaching some interfaces for the messages that will be consumed. The messages are the events, and the class is the saga. An example saga is shown below.

   public class DrinkPreparationSaga :
        InitiatedBy < NewOrderMessage >,
        Orchestrates < PaymentCompleteMessage >,
        ISaga
    {
        public void Consume(NewOrderMessage message)
        {
        }

        public void Consume(PaymentCompleteMessage message)
        {
        }
    }

I’ve omitted the code for each consumer to keep it short, but the business logic defined would handle the fact that once the drink is prepared, it should not be served until the PaymentCompleteMessage has been received. Storing this state is an application concern.

While I was at QCon San Francisco, I attended a tutorial session on DSLs. It was here that I got the idea to somehow make a DSL for defining the behavior of a state machine that could be used with sagas in MassTransit. It’s taken a couple of months, but I think I’ve managed to put something together that simplifies state management in sagas. With the addition of a new state machine in Magnum, along with persistence support for NHibernate, it is now easy to manage this state automatically.

To demonstrate this, below is the state machine for the above process.

	public class DrinkPreprationStateMachine :
		StateMachine < DrinkPreprationStateMachine >,
		ISaga,
		InitiatedBy < NewOrderMessage >,
		Orchestrates < PaymentCompleteMessage >,
		Orchestrates < DrinkPreparedMessage >
	{
		static DrinkPreprationStateMachine()
		{
			Define(() =>
				{
					Initially(
						When(NewOrder)
							.Then(saga =>
								{
									// start preparing the drink
								})
							.TransitionTo(PreparingDrink));

					During(PreparingDrink,
						When(DrinkPrepared)
					       	.TransitionTo(WaitingForPayment),
						When(PaymentComplete)
					       	.TransitionTo(WaitingForDrink));

					During(WaitingForPayment,
					    When(PaymentComplete)
					       	.Then(saga =>
					       		{
					       			// publish drink ready message
					       		})
					       	.Complete());

					During(WaitingForDrink,
						When(DrinkPrepared)
					       	.Then(saga =>
					       		{
					       			// publish drink ready message
					       		})
					       	.Complete());
				});
		}

		// event and state definitions not shown, but are simple properties
	}

As shown above, all the logic of states, events, and transitions is wrapped into a clean fluent interface. The During() blocks define what is to be done when events are received during a particular state. The When() blocks define the behavior when the specified events occur. All state transitions are explicit, allowing them to be captured as part of the state machine.

There are two types of events. BasicEvent supports an event without any accompanying data. The DataEvent < V > allows data to be associated with an event. In MassTransit, each DataEvent would have a matching Consume() handler. For example, Event < NewOrder > would have a public void Consume(NewOrder message) that would call RaiseEvent(NewOrderEvent, message) to pass the event to the state machine along with the message.

The state machine also supports inspection, allowing the definition to be output for verification that the intent was properly conveyed by the interface. This not only makes it possible to verify the flow between states, but also could allow the creation of a graph to display the states, events, and transitions in a visual manner. The provided state machine inspector currently only outputs to the trace window, but could easily be enhanced by somebody with some skills.

Also, not shown above, is the ability to specify an expression using the .And() method to evaluate the data associated with an event to determine if that event is handled by that state event action. This expression is kept as an expression, allowing the details to be output using the inspector as well.

Currently, the saga must still implement the Consume() method for each message and call RaiseEvent() on the state machine to pass the message and trigger the event. I plan to add some new message sinks to the message pipeline to make those methods unnecessary, mapping the messages directly into the event handlers within the state machine. This isn’t done yet, but it is planned.

The StateMachine also provides an IUserType implementation for NHibernate in the Magnum.Infrastructure assembly. This makes it easy to persist the state using NHibernate, storing the current state as a string. This is just the default implementation, any other could be built if your needs are different.

I originally presented this syntax during the Virtual ALT.NET meeting last week. It was a last minute presentation, so I wasn’t sure I covered all the details. Hopefully this will help provide some guidance on how it is used, along with plans for the future.

Nov 05

Last weekend, Dru Sellers and I (along with 100 or so others) attended the Continuous Improvement in Software Development (referred to as KaizenConf, likely due to the URL) conference in Austin, TX. We left Tulsa late Friday night after taking my girls trick-or-treating for Halloween and drove all night arriving in Austin around 5:30 AM. After a quick nap and a shower, we went to the first day of the conference.

The night before at the opening, those who were there put up a series of topics that they wanted to discuss. One of those talks was on Enterprise Service Bus (ESB) patterns and implementations using MassTransit. I think it was pretty obvious where Dru and I were going to spend our time right after lunch. There were a number of people that we have had conversations with that also attended and they were excited to learn more about distributed application designs and how to implement them using open-source tools like MassTransit.

IMG_0093.jpg

The First Session: Alternative Architectures

After the morning announcements, Dru and I joined Ben Scheirman and Ayende Rahien in a conversations about alternatives to the RDBMS. The conversation started a bit rough, but quickly opened up into other ways to store data in our applications. Ayende brought up CouchDB and the things he learned about it. There was also some in depth discussions about proper use of databases and separating transactional data from reporting to avoid transaction blocks. Some concepts on how to achieve the appropriate separation, including asynchronous ETL (extract-transform-load) were discussed. The Map/Reduce algorithm was also covered and some examples were given in the discussion of how to map data into dimensions for reporting. The proceedings from this talk can be found on the wiki.

IMG_0094.jpg

The Second Session: Lean Architecture

My second session of the day was on Lean Architecture. This discussion was forward looking and related to how development teams could branch out and work on features with the intent of releasing individual features as they are complete (instead of waiting for a big release with many unrelated features). There was a lot of talk about how the teams work, how version control and build processes would need to adapt to handle the complexity of dealing with multiple development versions of a single code base. I think one of my biggest take aways from this session was the need for an integration branch that is created from the trunk before each merge. It is then possible to integrate a branch into the trunk without immediately impacting the trunk. Once the simulation branch merge is complete and tested, the simulation is merged into the trunk (which should be easy, since it was created from the trunk originally). This alone would help to ensure a solid trunk that can be delivered on demand. The proceedings from this talk are also on the wiki.

Over lunch we enjoyed some amazing Austin weather while talking about projects and recent events. We then went to setup for the discussion on ESB/MassTransit. Upon arrival, we were surprised at the number of people in attendance. There was a crowd of at least 20 people and the video crew was setup with remote microphones and the works. Once we had gotten the projector setup and demos loaded, we started into the discussion.

The Third Session: ESB Patterns and MassTransit

The conversation started with a general discussion about messaging patterns. A reading list was presented, along with the major patterns that are used in a publish/subscribe system like an ESB. Applications for this type of system including everything from a command/query interactive system to migrating a batch processing application to a more real-time asynchronous process. We touched on where MassTransit was in the development lifecycle and some of the things we learned over the last year of development. We showed some of the sample applications, including the new web service bridge sample for connecting external customer web services to an internal domain.

Needless to say, we were amazed at the response we got related to MT and ESB patterns in general. It was great to have Ayende and Jeremy Miller bouncing ideas around regarding the project and integration with other existing systems. The notes from the discussion are located on the KaizenConf Wiki.

The Last Session: A Mixed Bag

My last session of the day was split between two completely different sessions. One was on Advanced IOC usage, and the other was on moving from Project to Product. I bounced between these two sessions, picking up some interesting bits from each one. Both were late in the day, so I was fading pretty fast considering I only had 90 minutes of sleep the previous night. Good concepts were captured in the notes, so be sure to check those out (I’ll have to just to remember them).

After the sessions for the day, we went to the Hyatt with Ben (B#) and provided input as he started writing a new sample for MassTransit. The context for this new sample was the Gregor Hohpe article about how Starbucks Does Not Use Two-Phase Commit. This was mostly a learning exercise for Ben, however, we gained some insight watching him build it out. I think Dru refactored the host quite a bit to remove some extraneous ceremony that was just unnecessary. Once we had the first bits working, it was time to find some dinner and the rest of the gang. We had some great Tex-Mex at Trudy’s and then went back to the hotel bar to watch Texas Tech put the smack down on U-Texas Longhorns.

The next morning we met up at Starbucks (go figure) to complete the new sample Ben was building (yes, the irony of working on a sample about Starbucks @ Starbucks didn’t get past us). We ended up converting from using regular message consumers to a saga-based approach given the requirements and it took another 30 minutes to get it all working. Oren had some great ideas on how we could tweak little things here and there to eliminate some friction as well. Once we were done, we headed on over to the conference to see what was in store for the morning sessions.

This year, the focus of the conference was on continuous improvement. Therefore, instead of just having additional sessions on Sunday morning the attendees voted on sessions that they wanted to help improve. At least, that’s how I understood it, we were working on the Starbucks sample, remember? Anyway, when we arrived we found that the ESB Patterns session was one of the topics. The room was full with something like 22 votes on the page. I was surprised to see the response of the people, truly surprised.

Continuous Improvement: ESB Patterns and MassTransit

The actions are summarized on the wiki, and included things like documentation, more sample applications, and help on how to add messaging to an existing application. We also dug into the things needed to help people build and understanding messaging components in their applications. Things like diagnostics, conventions to avoid common missteps, hands-on labs to walk through building a message-based component, and a few other getting started items were brought up. From a technical side, we talked about additional patterns such as an overall conversation id to correlate multiple sagas (like a saga of sagas), as well as built-in support for compensation.

A large part of the discussion was on how functional programming features could be used to enhance the system. An example in Erlang of a message exchange was drawn up, along with how it might be written in C#. Matthew Podwysocki was consulted on how this example might be written in F#, and there was discussion about how the threading model of F# doesn’t really support the style used by Erlang. Some work is still needed there I suppose but we’ll continue to be open about the possibilities offered by functional languages. Glenn Block also talked about getting in touch with the connected systems group to see what they could offer.

IMG_0095.jpg
County Line BBQ

With that, the conference was closed. Once again, the open space technology used for the event was awesome. The rules of open space dictate that what happened is the only thing that could have happened, and I agree with that completely. It was great to be a part of yet another excellent event and I look forward to future installments in other locations. Be sure to keep up with the wiki, as videos from most of the sessions will be made available online soon. One of our improvements was to better document our proceedings, and I think we’ve managed to succeed on that one for sure.

Oct 12

This past Thursday and Friday, the Tulsa TechFest was held at OSU Tulsa in Tulsa (could I write Tulsa one more time, I knew I could). Attendance was high and most of the sessions I attended were in rooms full of people. The day started off early Thursday morning, but that’s not the start of the story.

The night before, Dru and Rob came by the house for a little pre-conference warmup (and by warmup, I don’t mean this). Rob went through his presentation on continuous integration one last time while Dru and I worked through our presentation on messaging (and how to do it with MassTransit, of course). The night ended early for me, but Rob and Dru met up with Ben at the hotel and closed the bar (and by closed, I mean walked in at last call and got one beer).

The next morning we all met up and caught up on things since the last gathering. Since the last time we saw Ben, he’d been through a hurricane and granted the MVP Award from Microsoft. We then planned out our day of sessions based on the information currently available to us.

The speaker for the CSS talk was unable to attend, so the four of us convened an open-space session on CSS. The discussion in the fishbowl was good with a lot of interesting topics. Ben gave an on-screen demonstration of CSS from the ground up for those in the room that were new to it, providing context for the audience. CSS is extremely important considering it is the best (only?) way to layout and style websites consistently across browsers. I think everyone brought up how much of a turd IE 6 is when it comes to CSS compatibility.

After lunch, it was time for Dru and I to present our session on message-driven architecture (using MassTransit). You can see the first hour of the session on video here. The crowd really got into it, asked a lot of questions, and hopefully came away with an understanding of asynchronous application design and messaging.

After that session, we sat down with a guy that works for Sun and talked about enterprise application architecture. It was interesting comparing the mature open-source nature of Java to the budding open-source landspace in .NET. After the closing session and prize giveaway, there was a speakers dinner (Rib Crib, good stuff). Once we had eaten, we went to the hotel and did a little code sharing and Dru and Ben went through ASP.NET MVC some more. Then we went over to Dirty’s Tavern for some post-day fun. I was worn out, so I went back to my car and called it a night.

The next day was full of interesting stuff. A nice introduction to ASP.NET MVC by Ben, some extensive coverage of log4net by Dru, and I gave a presentation on iPhone development. Outside of the actual sessions there were a lot of great conversations about development and tools in general. We also recorded Ray Lewallen’s session on Behavior Driven Development, which can be viewed here.

My iPhone development session was purely introductory to show the tools and how they are used to build and deliver applications for the iPhone. The room was absolutely packed and hopefully everyone walked away with some good information. I know at least one guy did, he left two seconds after I said that building iPhone applications requires a Mac!

To wrap it up, the event was a huge success. There were a ton of people there, the vendor room was always alive with activity (likely due to Chris Koenig and his Rock Band setup giving some much needed ADHD relief between sessions). Chris also had a couple of great sessions on Silverlight and the new features in 2.0 that should really improve the use of Silverlight for Rich Internet Applications (RIAs).

Apr 29

After a great weekend in Seattle for the ALT.NET Open Spaces event (aside from a slight error in judgement on Friday night as depicted in this blog post), the two coworkers and I discussed how we could bring the experience of Open Spaces back to the team in Tulsa. We decided that instead of just giving a few talks about some of the things we took away from Seattle, we would bring the experience itself to the team.

At the end of our team meeting on Monday, we laid out some paper and pens and asked members of the team to write up topics that they wanted to discuss. It started a bit slow, but within minutes we had eighteen topics on the wall. The variety of topics was excellent, most of which targeted a different subset of the team. It was great to see the team come up with such a nice list of things for the team to discuss.

We then drew a grid of time slots on the whiteboard and asked the team to put their initials on the topics they wanted to attend. As the papers filled up, we started aligning them into the grid based on popularity and expected duration. We tried to keep all of them to an hour but some of the topics were given ninety minutes based on the content.

We had to negotiate on some of the topics to fit our time slots, and combined a couple of similar discussions into the same time period so that we could maximize our coverage over the next few days. Some topics were brought up that are timely to an upcoming release of our software, so those were given a slight priority in the schedule.

Overall, I was very impressed with the contributions by the team. Topics included things like “maximizing the use of Resharper”, “What are unit tests”, and “How can we test better?” With the large number of topics on the schedule, we’re hoping that we can set aside a couple of days a week (maybe Tuesday and Thursday over lunch) to continue with more discussions. I’ll be sure to post a follow up as things unfold over the next week.

Apr 27




Roy Osherove, Dru Sellers, and Me

Apr 18

While I’m trying to keep my posts at pace with the event here in Seattle, it gets harder as more attendees arrive. Yesterday, Evan Hoff showed up and we took another trip down to Pike Place Market for some food and festivities. After an afternoon of good conversation, we went to Kells Irish Pub to meet up with Ayende and Udi (along with some other folks) to talk about software architecture.

The variance in perspective between different architects is always interesting, and this meeting did not disappoint. Recognizing the strong points in each design style was helpful by understanding the background of each approach. I’m looking forward to more of that this weekend.

The weather turned completely crappy today (technical term, sorry), as it is cold and wet. We still managed to run about and snag some chow before things get fired up tonight. A pretty solid crowd is overflowing the lounge in the hotel and you can tell there is some energy building.

We’re about to head that way to get the final things wrapped up and organized. Look for more later tonight (or tomorrow if the talks get deep)!

Apr 17