Slides from “An Agile Retrospective” at codepaLOUsa 2013

One of the major take-home stories not me toned in the slides is to not define your identity by your process. Don’t trap yourself in a less than optimal process by proclaiming it’s the right way, or the one true way. From the start, accept the idea (and let others know) that your overall process is a slowly changing dimension in your enterprise. Leave yourself room to adapt and grow as you and your team becomes more practiced and new tools/techniques emerge.

If you attended my talk, I deeply apologize for the technical issues. Karma’s a bitch, for sure. Run-through in my room before the talk went great, with the most up-to-date slides. Being too smart to leave Powerpoint open while I came downstairs, I closed everything down. Joking with Steve from Geeks and Gurus about his projector and my new laptop was all in fun (Steve and I have known each other for several years now, poking fun at one another is nothing new). Perhaps also making sarcastic remarks about demo gremlins, Windows 8 and the conference wifi was tempting fate a little too much. I’m still perplexed as to whether “Your changes cannot be discarded” would have been a good thing or a bad thing. In addition to the out of date slide deck I had to use, this website was down, and my laptop blue screened right as I walked out of the room. So it was exciting. From what I can gather, between the time I logged onto the conference wifi and opening my slides I must have been knocked off the network, so a local cache of an older version was found, and why I could never get the latest slides loaded. My laptop wasn’t displaying that I was disconnected, the cause of which may have been part of the BSOD.

Anyhow, my site seems to be working again, I got the laptop happy and was able to recover the correct slides from SkyDrive. Without further ado, here are the annotated slides for An Agile Retrospective. Note: file is hosted on SkyDrive, but it should be a public link.

Latest Refcardz – Agile Adoption: Improving Software Quality

Agile Adoption: Improving Software Quality

This Refcard is a quick introduction to Agile practices that can help you improve the quality of your software  by reducing defects, improving design, sharing the theory of the code and building less.  It includes an introduction of how to choose the practices for your organizational context.

Get a free download at http://refcardz.dzone.com/refcardz/agile-adoption-improving?oid=hom13299

Getting Started with TDD using MbUnit and C# and VB.NET

There is a lot being written about Test Driven Development in the .NET world.  So much so that it can seem overwhelming to absorb, and you always feel like you’re entering in the middle of the conversation.  Yep, me too, even four years ago when I first dipped my toe into the TDD pool.

After a couple years in SSRS/BI-land, it’s back to regular development, and back into the TDD pool.  The pool has matured–there are new tools, stronger opinions, and much more conversation.  Essentially, I’m starting over, but with a little experience.  In this post, I’ll show you what I’m setting up, and how to get started with a simple project.

What to use?

There are a number of applications available, each with its own adherents and detractors.  Some are free, some you buy.  If you have Visual Studio 2008 Professional or better, you have a testing tool built in.

I tried a couple tools getting started, including NUnit and MbUnit.  I preferred MbUnit, so I downloaded the latest version, part of the Gallio Automation platform.  Gallio/MbUnit is one of the more popular TDD applications.  It’s well supported and well documented, which helps greatly.

So what is Gallio and MbUnit?  Simply understated, MbUnit v3 is a set of classes for unit testing, and Gallio is what actually runs the tests and displays the results.  Gallio can run more tests than just MbUnit, and integrates with build tools.

Installation was a snap–I downloaded the installer and let it run.  Gallio integrated with VS 2005 and VS 2008 automatically, but had an issue loading a language pack when I started VS 2008.

Planning what you’re coding

Before you start hacking away on the keyboard, you need to figure out what you’re writing.  You can use whatever project management methodology you want.  Here’s a user story for something I encountered recently:

For our space utilization analysis, I need to be able to easily take an order date, and figure out the date the week ends on, so I can accumulate inventory changes to the same base date.  I need to be able to specify the end date, since calendar and fiscal weeks may have different end days.  Dates should be calculated back from the given date.  If the the weekday of the given date, and the week end day are the same, then the given date should be used.

Test first!

One of the tenants of TDD is writing your tests first, called the “red, green, refactor” cycle of development.  Red refers to a test which fails, green refers to a test which passes, and refactor refers to reworking the code you wrote to make the test pass to make it leaner.  This takes some realignment of your thought process, but gets easier as you do it.

Open Visual Studio, and create a new project.  I’m calling mine DateLibrary, since I’m actually creating a library of date functions useful to me.  Delete the automatically created Class1.

We need to separate the tests from the code we’ll use in our applications, so our tests don’t end up as part of the application.  Add a second class to the solution, called DateLibraryTests to contain the tests.  Again, delete Class1, and add one named WeekEndTest.  Add references to your class library project, Gallio and MbUnit, and then add using statements, as shown:

C#:

using System;
using DateLibrary;
using MbUnit.Framework;

VB.NET:

Imports System
Imports DateLibrary
Imports MbUnit.Framework

Now, let’s write our first test.  To reiterate, one of the tenants of TDD is writing your tests first.  Realistically, you might need to write a little application code first.  I prefer to have a little Intellisense guide my test writing, so I just stub out a class and methods, just enough so my app will compile, but no actual code.  In our example, we need to return something, so we just return a blank date and time.  Here’s the code stub:

C#:

using System;
namespace DateLibrary
{
    public class WeekEnd
    {
        public static DateTime BackDate(DayOfWeek EndDay, DateTime FromDate)
        {
            DateTime _backdate = new DateTime();

            return _backdate;
        }
    }
}

VB.NET:

Imports System

Public Class DateLibrary

    Public Function BackDate(ByVal EndDay As DayOfWeek, ByVal FromDate As Date) As Date
        Dim _backdate As New Date

        Return _backdate
    End Function

End Class

The first parameter of our method is the day to figure back to, and the second is the date to figure from.  We use a DayOfWeek for the first parameter to limit input values.

One of the criticisms of TDD is that everything you want to test must be public, since tests are placed in a separate class.  So if you plan on having private methods and classes, you’re either out of luck, or you can change the modifier after your tests are run, have public accessors to your private methods, or include test code in your application.  What you do is up to you, based on the local coding standards and application design.  For this sample, public methods are just fine.

Now we write our test.  In TDD, Assert basically means “I am expecting these values…”.  So, our test case could be thought of as “I am expecting these values are equal”.  The values to be compared are the one we’ll calculate from our code above, using inputs which we already know the answer to, and the answer we already know.  Our test looks like this:

C#:

using System;
using DateLibrary;
using MbUnit.Framework;

namespace DateLibrary
{
    public class WeekEndTest
    {
        [Test]
        public void WeekEndsSunday()
        {
            Assert.AreEqual(new DateTime(2009, 06, 21), WeekEnd.BackDate(DayOfWeek.Sunday, new DateTime(2009, 06, 25)));
        }
    }
}

VB.NET:

Imports System
Imports DateLibrary
Imports MbUnit.Framework

Public Class WeekEndTest

    <Test()> _
    Public Sub WeekEndsSunday()
        Assert.AreEqual(CType(<span class="str">"6/21/2009", Date), WeekEnd.BackDate(DayOfWeek.Sunday, <span class="str">"6/25/2009"))
    End Sub

End Class

The [Test] attribute is used by the test runner to find the tests from the regular methods.

Make sure the solution compiles without errors.  If it does, it’s time to run our tests.  Gallio/MbUnit includes the Icarus test runner, which provides easy to read graphical feedback.  To start Icarus, navigate Start >> All Programs >> Gallio >> Icarus GUI Test Runner.  Once Icarus has started, we need to load in our tests.  Go to Project >> Add Assemblies, navigate to the bin folder of your test project, select the test DLL and click Open.

SS-2009.06.27-15.15.12

The tests will be parsed, and listed in a treeview.  You can add as many test DLLs as you need, we just have the one for this example.

SS-2009.06.25-22.30.57

Click the Start button, and our tests will be run.  The Execution Log shows the results, in this case, red, just like we expected.

SS-2009.06.25-22.34.37

Further down, you can see the expected and returned values.  Our test failed (as expected) because a blank date was returned, and did not match the expected value.

SS-2009.06.26-20.26.48

Great.  Like we said above, “red, green, refactor”.  We now have red taken care of.  Before we do anything else, let’s do a quick sanity check to make sure all systems are correct.  In our test, we’re expecting the returned value to be 6/21/2009.  As a test of our tests, let’s change our procedure slightly to make sure it returns the expected date, and run our test again.  The results should be green.

C#:

using System;

namespace DateLibrary
{
    public class WeekEnd
    {
        public static DateTime BackDate(DayOfWeek EndDay, DateTime FromDate)
        {
            DateTime _backdate = new DateTime(2009, 06, 21);

            return _backdate;
        }
    }
}

VB.NET:

Imports System

Public Class WeekEnd

    Public Shared Function BackDate(ByVal EndDay As DayOfWeek, ByVal FromDate As Date) As Date
        Dim _backdate As New Date

        _backdate = "6/21/2009"

        Return _backdate
    End Function

End Class

Sure enough, our results are green.  This does not satisfy the green portion of “red, green, refactor”, this is merely to confirm our systems are working correctly.

SS-2009.06.26-20.34.03

Now it’s time to write some actual application code, and have our test be green for real.  From the user story above, we arrive at the following code:

C#:

using System;

namespace DateLibrary
{
    public class WeekEnd
    {
        public static DateTime BackDate(DayOfWeek EndDay, DateTime FromDate)
        {
            DateTime _backdate = new DateTime();
            int _dayOfWeek = new int();

            _dayOfWeek = (int)EndDay;

            if (FromDate.DayOfWeek == EndDay)
            {
                _backdate = FromDate;
            }
            else if ((int)FromDate.DayOfWeek &gt; (int)EndDay)
            {
                _backdate = FromDate.AddDays(-(int)FromDate.DayOfWeek - (int)EndDay);
            }
            else
            {
                _backdate = FromDate.AddDays(-(int)EndDay - (int)FromDate.DayOfWeek);
            }

            return _backdate;
        }
    }
}

VB.NET:

Imports System

Public Class WeekEnd

    Public Shared Function BackDate(ByVal EndDay As DayOfWeek, ByVal FromDate As Date) As Date

        Dim _backdate As New Date()
        Dim _dayOfWeek As New Integer()

        _dayOfWeek = CInt(EndDay)

        If FromDate.DayOfWeek = EndDay Then
            _backdate = FromDate
        ElseIf CInt(FromDate.DayOfWeek) &gt; CInt(EndDay) Then
            _backdate = FromDate.AddDays(-CInt(FromDate.DayOfWeek) - CInt(EndDay))
        Else
            _backdate = FromDate.AddDays(-CInt(EndDay) - CInt(FromDate.DayOfWeek))
        End If

        Return _backdate
    End Function

End Class

Now, we run our test again, to make sure our code does what we think it will do:

SS-2009.06.27-15.21.09

 

Success!  This time, we’re green for real.  The final part of the TDD is to refactor.  Refactoring is a process of editing your code to make it more concise, more maintainable, and more reusable.  It’s not an entirely simple process, requiring a good deal of thought.  The best part about TDD is that as you refactor, you can easily tell if you’ve broken your code by running your tests again.  It’s a process we won’t cover here.

 

 

 

 

For more information

To learn about and download MbUnit and Gallio, go to http://www.gallio.org/.

For a deeper look into TDD, the book recognized as starting it all is Test Driven Development By Example, by Kent Beck.  The examples are in Java and JUnit, but this is the book recognized as the authoritative work on TDD.

If you’d prefer to have examples in .NET, you might like Test Driven Development in Microsoft .NET.  James Newkirk is a leader in Agile development, and is one of the founders of NUnit and xUnit.

DotNetKicks Image

Using Mocks and Stubs and Free TypeMock Licenses

Blogs are a fabulous way to share knowledge, and for incremental learning, but they’re a tough way to grok an entire underlying concept.  Something I’ve never quite grokked are mocks and stubs, until last week.  My favorite development mag’s latest issue is dedicated to open source tools in .NET development.  One article focuses completely on mocks and stubs, Isolating Dependencies in Tests Using Mocks and Stubs.  After reading this, I thought "wow, I need to get me a mocking framework".  One of the popular mock frameworks mentioned was TypeMock.

Enter TypeMock today.  A short time ago, I get this in my FeedDemon:

Unit Testing ASP.NET? ASP.NET unit testing has never been this easy.
Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle – and for the launch will be giving out FREE licenses to bloggers and their readers.

The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both Typemock Isolator, a unit test tool and Ivonna, the Isolator add-on for ASP.NET unit testing, for a bargain price.

Typemock Isolator is a leading .NET unit testing tool (C# and VB.NET) for many ‘hard to test’ technologies such as SharePoint, ASP.NET, MVC, WCF, WPF, Silverlight and more. Note that for unit testing Silverlight there is an open source Isolator add-on called SilverUnit.

The first 60 bloggers who will blog this text in their blog and tell us about it, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET dedicated blog, you’ll get a license automatically (even if more than 60 submit) during the first week of this announcement.
Also 8 bloggers will get an additional 2 licenses (each) to give away to their readers / friends.

Go ahead, click the following link for more information on how to get your free license.

Serendipity, baby!  Hope I’m one of the first 60.

DotNetKicks Image

Simple Design and Testing Conference Coming to Pittsburgh

SDT Conf is focused on providing agile practitioners a platform to meet face-to-face and discuss/demonstrate simple design & testing principles/approaches. The conference will use Open Spaces to structure conversation, improve understanding, facilitate brainstorming and help innovate.

  • What: Open Space event to discuss different aspects of the Simple Design and Testing practices
  • Where: Pittsburgh Supercomputing Center, Pittsburgh, PA, USA
  • When: Oct 9 – 11, 2009
  • Who: Everyone interested in Simple Design and Testing practices
  • Cost: Free. Open to people from all aspects of software projects

SDT Conf Fall 2009 is our fourth annual conference. SDT Conf 2006, 2007 and 2008 were very successful conferences. More details on the Archive page.

Full story at http://sdtconf.com/

DotNetKicks Image

Dynamsoft Releases the World’s First Hosted SCM Solution!

I’m sure Rally Software or Axosoft might beg to differ about the "world’s first" claim, but there’s another contender in the SCM/Hosted SCM arena:

Today we are pleased to announce the release of Dynamsoft SCM Anywhere Hosted, the world’s first hosted Software Configuration Management solution.

With integrated version control, issue tracking & build automation, SCM Anywhere Hosted is specifically designed for teams looking for an integrated Software as a Service (SaaS) solution to manage the entire software development life cycle.

With SCM Anywhere Hosted, development teams can achieve great benefit from the simplified IT infrastructure, the lowered cost of ownership, the high availability with anywhere/anytime access, the uncompromised security, and also the excellence of other features.

For more information about SCM Anywhere, please visit:
http://www.scmsoftwareconfigurationmanagement.com/
A 10-minute introduction video can be found at:
http://www.dynamsoft.com/Products/WebinarVideo/SCMHWebinar.aspx

Features of note are CruiseControl.NET and ANT integration (even in the hosted version), source control with SourceAnywhere, and three users free (hosted; installed=1 user).

I’ve used Dynamsoft SourceAnywhere for a while now, and it’s really nice.  The Visual Studio integration is almost perfect, and the workflows are up to part with Subversion.  If the SCM compares to SA, expect good things.

DotNetKicks Image

Cheap offsite version control

If you’re any sort of developer, one of the most important tasks you can do is secure your code—not just keeping a good version history, but also keeping the code in a safe place in case your computer fails or house is destroyed.

Most of us have a hosting plan which we use to tinker and host our own personal stuff.  Mine has far more disk space than I’m likely to use, plus the drives are backed up and securely located—just the kind of thing you need for your source code.

There are a number of inexpensive options to maintain your code on your own hosting plan.  One is FTPVC, which I’ve covered before.  FTPVC combines revision control and FTP upload to your hosting plan in one convenient package.

If you want to use a more popular  source control option, such as Subversion/TortoiseSVN, you can.  TortoiseSVN has a local folder mode, which means you can turn ordinary folders into repositories without installing a full Subversion server.  You can map an FTP folder as a local folder with a tool like NetDrive.

There are all sorts of other options available that will accomplish the same thing, and it doesn’t really matter what you use, just so long as you’re securing your code.

DotNetKicks Image

Adopting Scrum: Scrumboard in a Cube

In Agile Software Development with Scrum, the authors recommend setting up a permanent scrum room, where the dev team can meet and where a scrumboard can be established.  Wouldn’t that be lovely?  In the real world I’m in, it’s tough enough to get a conference room for an hour, let alone permanently assigned.  We hold our daily scrum in the lunchroom, and depending on which weathergirl is doing the forecast on the TV (welcome back, Julie Bologna), I can usually hold my team’s attention.

For my scrumboard, I had to get a little creative.  I ordered a bunch of magnets, and turned one of my wall panels and hutches into my scrumboard.  My project backlogs live on the wall panel:

DSC_6253Small

Tasks we’re working on start in the sprint backlog on my hutch.  As the rented mules dev team members progress on a task, they move it from from one status to another as indicated by the top row of index cards.  When a task is completed, they can grab another one from the backlog (this current sprint is winding down, so there are no tasks in the backlog).  The colors of the magnets have no meaning, but the diameter gives you a quick indication of the depth of each status pile.

DSC_6252Small

A scrumboard on my hutch is one of the reasons we’re writing Scrumr, which will replace all these magnets and index cards with a web based application.

Almost Native Subversion Support from Codeplex

This is awesome news:

CodePlex is now offering server support for SvnBridge, the tool that enables TortoiseSVN to talk to Team Foundation Server. Support for Subversion has been our number one requested feature, and by hosting SvnBridge, our users can now use their favorite Subversion client with any project.

Starting today, TortoiseSVN will just work as illustrated below, no extra software is necessary to work with CodePlex.

Kudos to the CocePlex team!  Who says Microsoft doesn’t listen to feedback, or make an effort to support open source tools?  Bah!

The SvnBridge client wasn’t bad, but it was kind of a pain to have to start it to check out or commit changes.

Full story at http://blogs.msdn.com/codeplex/archive/2008/09/14/codeplex-launches-support-for-tortoisesvn.aspx.