Skip to main content

Windows Workflow: Re-introducing old anti-patterns?

As part of my day job I've been experimenting with Windows Workflow in both modifying the existing TFS2010 build templates and as a way of controlling the process flow in our new suite of applications. On the most part I've been really impressed; when you sit in a process workshop watching the business users mapping the existing steps out on a white board (or even a wall) it is quickly apparent that showing them a similar flow should hold significant benefits. Gherkin goes some way towards creating a syntax/language that works for both technical and non-technical people, but it is a test language verifying the application is working as intended - you don't write the process itself in gherkin. We've also found (from experience) that gherkin has a reasonable learning curve for both technical and non-technical users; whilst most people seem to find it easy to relate to the visual element of workflow with little or no training.

But as I opened I've been impressed for the most part with what I've seen of workflow so far. Over the past 10 years or so there has been a significant push to improve the quality of code that is produced. We have unit tests and TDD, guidelines such as SOLID and DRY all designed to aid the developer in creating code that should be easier to maintain and less bug-ridden. This has all helped and it's not often that you should come across methods inside of a class that remind you of the days of classic ASP and/or VB6 with massive blocks of procedural code containing large conditional sections of code; harbouring numerous responsibilities, reasons to change and worse still, code that can't be tested in isolation(*).

Getting back to workflow re-introducing old anti-patterns, step forward the default build template for TFS2010. I'm not sure how many people have taken a look at this workflow, or worse still had to work with / modify it? That nice happy feeling of replicating what the business wants quickly vanishes and it's like taking a step back in to code from the early 90's. Everything (and I mean everything) is in one single workflow. In the designer, even at 50% scale, you have to scroll down several pages to move through one conditional block of code. Want to find where a particular exception is thrown, it's probably quicker to open up the workflow as plain XAML and text search for the exception type and/or message text. Even if you figured out how to host the workflow to test it, if you want to test the "gated check-in" functionality you'll have to run the entire workflow from start to finish just to reach the code under test. Want to isolate a hard to test entry point into the gated check-in workflow; you'll have to figure out the exact scenario to replicate it because you can't set it up or Moq the areas you're not interested in. Sound familiar, I'm sure everyone's worked on a code base that suffered the same problems but in real code we're mostly past those problems now.

It doesn't have to be this way, workflow allows sequences and flows to be declared in separate XAML files and nested inside a larger workflow. There's absolutely no reason why the gated check-in sequence could not have been it's own XAML file; with it's own in/out arguments. It quickly becomes SOLID and DRY - it only needs to change when the requirements or process for gated check-in changes and can easily be tested in isolation. I might not be able to figure out how to host / run the entire build template, but even now I'd probably be able to throw together a workflow host application that loaded, set-up and ran a "gated check-in" XAML file.

So workflow doesn't have to re-introduce old anti-patterns but all the time we have real-world examples that contain bad practises it will be harder for less experienced developers not to replicate. It's probably worth remembering that there are many developers that have come into the workplace never having to suffer the pain of procedural code that generated many of the recognised anti-patterns. It would be a big step back for development (and workflow) if examples like TFS became common place! As a side project I'm trying to gain a full understanding of the default build template (something that also seems to be missing from the on-line Microsoft TFS documentation) and break the XAML into smaller, focused sequences / flows that are easier to understand. Workflow does look like it can successfully be the procedural glue that handles the transition between state and complex / long running process flows; but it does need to adhere to the same testing and principles as the code it contains!

(*) This sort of code might still exist but I'm happy to say that I've been lucky to work in and with teams that don't produce it.


Popular posts from this blog

Why do my Android Notification only appear in the status bar?

I'm definitely getting back into Android development, I'm remembering that feeling of 'Surely this should be easier than this!'. All I wanted to do was to schedule a local notification which behaved similar to a push notification pop-up. That is, as well as showing the small icon in the status bar I wanted it to pop up on screen to notify the end user. All seems fairly easily, I found this code for how to schedule a notification. That all worked perfectly, apart from the notification would only appear in the status bar. Searching around I found loads of different answers / solutions, mostly all saying the same thing:It only worked if you used 'NotificationCompat.Builder' in place of 'Notification.Builder', orYou had to set the priority to 'NotificationCompat.PRIORITY_HIGH'As usually happens, none of these solutions worked for me until I added in the missing piece of the jigsaw:- '.setDefaults(Notification.DEFAULT_ALL)'. For me this…

IPhone hangs when running from XCode

I've had this happen a couple of times now and the first time was a little worrying that I'd bricked my iPhone. Basically I was running an application on my phone via XCode and when rebuilding an updated version it failed with a "busy" error message. Stopping XCode and unconnecting my phone had no effect, the phone was stuck displaying the loading screen of the application and wouldn't respond to any key commands. To fix you have to hard reboot, holding the power and home button until the phone reboots - doesn't lose any of the data you have on your phone (a concern the first time I did it).

Do "Task Hours" add anything in Scrum (Agile)?

What do task hours add to the overall process in scrum?This was a question that has arisen from all team members in both instances that I've helped teams switch over to scrum. The benefits of artifacts like the comparative story point estimation, the 2 week sprints, stand-ups and the end of sprint demo have been self evident to the team, but as one I think every team member has expressed dismay when it comes to task planning and estimating each task in hours. Left unchecked there is a natural tendency for people to actually begin to dread the start of each sprint purely due to the task planning session.In my current role we've been lucky to investigate this further as a team.The team sat down to discuss the problems it was experiencing with estimating tasks in hours and the following common themes appeared:It is hard: Maybe it shouldn't be, but time estimation is hard! Story points are comparative and abstracted making them easier to determine, but time estimate is gen…