Tuesday, November 27, 2007
Full-time "Gig"
We have a fairly large team (~15) of software developers, user interface designers, and Flash designers.
Tools are not the most important part of a company, but they can tell you about the "development eco-system". What do these tools tell you about our eco-system?
Subversion
NHibernate
NUnit
Log4Net
Rhino Mocks
NAnt
Twin$
To prepare, we are building a new 4 bedroom home west of Jordan Creek Town Center.
Wish us luck!
Wednesday, June 27, 2007
One Simple Metric
Here is the (simple) equation:
Cyclomatic Complexity (CC):Let's look at a couple examples:
Usage (U): How many other methods/classes rely on this code.
Test Coverage Percentage (TC): The percentage of the code that is exercised by a unit test
Risk Factor = CC x U x (1 - TC)
This first table shows a method used by 50 other methods (Usage) with a Cyclomatic complexity (CC) of 20. I then vary the code coverage for this method. Without any unit tests, the risk factor is a cool "g" (or Grand). As the test coverage increases the Risk Factor decreases. When the test coverage reaches 100%, the Risk Factor is reduced to zero. The function is linear, so decreasing the usage or the complexity will also reduce the Risk Factor. So it make sense that if a method isn't used, it has a risk factor of zero.
CC | Usage | Code Coverage | Risk Factor |
---|---|---|---|
20 | 50 | 0 | 1,000 |
20 | 50 | 0.1 | 900 |
20 | 50 | 0.5 | 500 |
20 | 50 | 0.9 | 100 |
CC | Usage | Code Coverage | Risk Factor |
---|---|---|---|
10 | 50 | .5 | 250 |
50 | 10 | 0.5 | 250 |
50 | 50 | 0.9 | 250 |
Thursday, June 21, 2007
Lean is the new Agile
I'm happy to see more people everyday are interested in Agile methods, however I'm saddened by the misinterpretation and perceptions of Agile by people who have never experienced it.
I've discovered that when I mention Agile to a group of IT Professionals, there is an initial reaction of shock and defensive posturing.
"Agile isn't for us. We don't want the developers coding without any direction."
or
"If we're going to use XP, that's fine. I'll just find another team!"
It's hard enough to have people listen about the spirit of agility when they have already made their minds up...which leads me to the topic of this post.
Lean is the new Agile
Recently I've been hearing more and more about Lean software development. It's not new, but I believe the agile community is looking for another way to market agility outside the software industry. And it makes sense to use Lean Manufacturing as the model. Every business person in the world has heard about lean manufacturing. Not only have they heard the term, there is an engrained positive feeling about it. Lean sounds like it costs less with more quality. They associate lean with Toyota which they associate with quality...Oh what a feeling!
Agile, on the other hand, is associated with XP (Extreme Programming). Nobody in business wants anything to do with anything that is extreme. Extreme equates to Risk and the business world is all about reducing risks (or as we say, "mitigating risks").
So give it a shot. Next time someone is discussing your software development methodology, tell them you use a lean software development methodology based on the principles from the Toyota Production System and see how they react.
Sunday, June 10, 2007
Single or Multi Threaded Projects
There are two strategies to complete the things you want to get done:
- Start them all at the same time
- Work on one at a time until it is completed, then work on the next highest priority
How do you do it in your daily life? If you have a list of tasks that you need to get done which approach do you use?
Let's think about how your company completes project. Which approach do they use? Are they the same?
Let's weigh the Pros and Cons of each approach. Let's assume your team needs to complete 3 similar sized projects (Project A, Project B, Project C) within 3 months.
Start all the projects at the same time (Multi-threaded)
Pros:
All project stakeholders are told their project has started
Cons:
Tracking each project's status is difficult
People on the project frequently have to switch thinking between each project
Each project will take 3 months duration to finish
Don't start earning returns on the projects
If there are overruns, each project is affected
One project at a time (Single-threaded)
Pros:
Only need to track a single project at a time
People on the project are focused
Each project should finish in one month
Project A will earn returns for 2 months
Project B will earn 1 month of returns
Overruns affect fewer projects
Cons:
Project stakeholders are told their project hasn't started
Am I missing any Pro/Cons for either of these scenarios?
Thursday, May 10, 2007
Things I've learned on my new project and why VSTS unit testing tools suck
I recently started working with a new team and like any time you start something new there is a rush of learning that occurs. I would like to share some of what I've observer/learned while working with this team over the last few weeks. These are my opinions and subject to change...
1.) Visual Studio 2005 Unit Test (MS TEST) Runner is awful!
Don't get me wrong, I'm glad that Microsoft has a unit testing framework integrated with the IDE (as long as your using the "ultra" Team Suite edition). For most Microsoft devs, if it isn't baked into the IDE, they won't use or acknowledge the value of the technology.
Back to what makes the baked in tools so bad:
a.) All these views and the one that I want doesn't exist!
Do you need the Test Manager, the Test View, the Test Result or the Test Result Detail window? Don't ask me, because I haven't figured out a good way to use them...yet.
If you don't know the difference between the views, here are some thumbnails. Click on the image to see a larger version. You tell me which one I should use (and you can't say TestDriven.NET).
Worst of all the "xUnit" view doesn't exist. A simple tree view in the left pane with a console window on the right to view exceptions and output values.
I'm using James Kocacs' VstsUnit Plugin for ReSharper. (A huge Thank You to James) It gives me what I need.
![]()
b.) Unit test architecture is slow
They must be copying the test assemblies to another location and starting another process. It is slow! I'm a firm believer that a unit test should execute in less than a 100th of a second (no dependencies on external systems - Yes, the file system is an external system.), and my unit tests still take multiple seconds to respond with the first result.
c.) Code Gen'd Accessor class feels dirty
If you haven't worked with the the VSTS testing tools, then you don't know about the class that Visual Studio generates for you. This code-gened class wraps the class you are testing and thru the magic of reflection, allow you access to private fields, properties and methods.
I both love and hate this. I love the convenience of it, but hate that it allows badly designed classes to be unit tested. The first sign that I've created a poorly designed class is that I can't unit test it....Actually that doesn't happen because I create a unit test first, but I do run into this when I'm trying to get legacy code into a test harness.
2.) Resharper = Love
I've been away from her too long, but I rekindled the flame with Resharper. Don't tell my wife!
3.) Developers need tools
Speaking for Resharper, the first question I will ask when I'm considering a project is, "Can I install software on my machine?" When you leave a company that won't allow you to install a font, you start to appreciate the little things that make you productive.
4.) Dual Screen Monitors = More Love
Now I have to find dual screen wallpapers
Sunday, April 22, 2007
Using Model View Presenter with VB6 ActiveX And .NET
I don't feel comfortable making changes to code that doesn't have test coverage, so I had to come up with a method to test VB6 ActiveX.
I figured that the ActiveX control was really just a view and I should be able to:
- Create the view Interface in .NET
- Create a Presenter class in .NET that works against the .NET view interface
- Expose the .NET view interface and presenter to COM and implement the view interface on the ActiveX control
Create the View Interface in .NET
The first step was to create a simple view interface for this example. I wanted to have a simple text property and buttons for navigating the documents and the pages within the documents.[ComVisible(true)]
[Guid("CC0FE3CD-BE47-46c4-81E9-08499EDF0633")]
public interface IView
{
string Name { get; set;}
ICommandButton PreviousPageButton { get; }
ICommandButton NextPageButton { get; }
ICommandButton PreviousDocumentButton { get; }
ICommandButton NextDocumentButton { get; }
}
I created another interface for the Command Button object. I did this so I wouldn't have to munge the view interface by including a "Visible", "Enabled" and "Caption" property for each button on the view. The ICommandButton interface looks like this:
[ComVisible(true)]You'll notice the Command button properties are Read Only. The view will return the CommandButton to the Presenter so the Presenter can get/set the properties on the ICommandButton interface. The presenter should not create a Button Control and assign it to the view. That is the responsibility of the view.
[Guid("B5482029-1671-4cc1-8BB7-979E933CF81B")]
public interface ICommandButton
{
string Caption { get; set;}
bool Enabled { get; set;}
bool Visible { get; set;}
}
Create the Presenter class
Next I create a simple presenter class. In order to work with VB 6 I had to do a couple things. First I had to have a default constructor. COM Interop needs a default constructor. Normally with the MVP pattern, you would create a constructor that takes in the IView interface, however VB6 doesn't support parameters in the constructor. Since constructor injection was a solution, I created SetView() method that takes in the view interface.[ComVisible(true)]
[Guid("867E8A4E-6D08-4c06-9B42-F9C8C12CEBDF")]
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Presenter
{
private IView view;
/// <summary>
/// Default constructor for needed for COM Interop
/// </summary>
public Presenter(){}
/// <summary>
/// Use Setter Injection since VB6
/// doesn't allow parameterized constructors.
/// </summary>
/// <param name="view"></param>
public void SetView(IView view)
{
this.view = view;
}
public void Initialize()
{
// Disable all the previous buttons
view.PreviousDocumentButton.Enabled = false;
view.PreviousPageButton.Enabled = false;
}
public void NextPage()
{
view.Name = "Next Page";
}
public void PreviousPage()
{
view.Name = "Previous Page";
}
public void NextDocument()
{
view.Name = "NextDocument";
}
public void PreviousDocument()
{
view.Name = "PreviousDocument";
}
private bool isEnabled = true;
public void ToggleAllButtons()
{
view.NextDocumentButton.Enabled = isEnabled;
view.NextPageButton.Enabled = isEnabled;
view.PreviousDocumentButton.Enabled = isEnabled;
view.PreviousPageButton.Enabled = isEnabled;
//Toggle
isEnabled = !isEnabled;
}
}
Implement the View in VB6
Go dust off your VB 6 we're going in!I had to implement the view and a class that implemented the ICommandButton interface. The view is easy. I have a class that I can implement the IView interface on, but how do I implement and interface on the class that already exists? Wrap it I guess. I created a CommandButtonWrapper Class that implemented the interface from the .NET Assembly. Once again I had to create a method to inject the CommandButton control.

The rest of the view is very basic and simple. All button click events are delegated to the presenter and the view properties return or set values on the controls of the view.
All in all this solution looks like it is going to work out. I'm concerned about a couple things, but hopeful that I can start test driving this ActiveX control. Wish me luck!