July 2008

Our team is comprised of 3 dedicated developers, 1 project manager, 1 super dedicated product owner and a trusty task board. Although, we're a small team we've been uber successful, and so far have been able to out perform the competition (in a surprisingly short amount of time).

One of those reasons is because of how "tight" (read:close) the team is. What I mean is that we're completely open with each other, which has allowed us to really gel as a team. We have our good days and bad days, but overall I feel like I can honestly depend on my team mates, and likewise.

We all make the same salary, and have the same amount of shares. There's no super heroes on our team. We all have strengths and our weaknesses, but there's no sense that any one of us feels like we are obligated to outperform one another. We're judged based on team performance rather than individual performance.

"The problem with reviews is that most reviews and raises are based on individual goals and achievements, but XP focuses on team performance. If a programmer spends half of his time pairing with others, how can you evaluate his individual performance? How much incentive does he have to help others if he will be evaluated on individual performance?" - Kent Beck from Extreme Programming Explained

Extreme Programming Explained: Embrace Change (2nd Edition) (The XP Series)
by Kent Beck, Cynthia Andres

Read more about this book...

Depending on the day, we each step up to lead the team. There's no water cooler discussions about why a member of the team makes x dollars, while I make x - 20K. We're either performing or not, and call each other out when we're not.

So far, this has helped our team gel. I'm curious to hear how about why you and your team are so "tight"?

So JP had to tag me... then the Los Techies crew had to invite me to join Los Techies. This sucks for someone who "claims" to be quite a private person. Thanks JP for putting me in the spotlight, and thanks to all the techies who thought I was fit to join. So here goes...

How old were you when you first started in programming?

I was in grade 11, so I guess that would have made me 15.

How did you get started in programming?

Hmm... Kind of by accident. I took a C++ course in high school as an option and I found that I actually liked it. I didn't actually think I was capable of becoming a software developer, but I knew I liked it.

What was your first programming language?


What was the first real program you wrote?

In college I signed up for a curriculum that focused more on electrical engineering than software development. However we got a little bit of exposure with different programming languages like assembler and C.

The first actual program that I finished was in my second year of college. We wrote a piece of voice recognition software using MatLab. It was actually a tonne of fun, because it required us to utilize what we had learned about digital signal processing as well as how to pick up a brand new language and learn how to get something compiling with it in a short bit of time. This was probably when I realized I liked staring at code more than I liked staring at circuit diagrams.

What languages have you used since you started programming?

Assembler, C, C++, C#, T-SQL, VB, VB.NET, MatLab. The languages I would say I'm ok in are C and C#.

What was your first professional programming gig?

Right after college I got scooped up by a company called DataShapers, where I got to work on a project called Incentus. It was a Gift Card, and Loyalty Management system. I was hired to build embedded gift card applications for different point of sale terminals.

I was quite fortunate that I got to work on such a sweet project right out of school. I was exposed to things like chip cards, 3DES encryption, SSL/TLS at a raw sockets level written in C. I was fortunate enough to be mentored by one of the best while I was there. Thanks Mr. Mark!

If you knew then what you know now, would you have started programming?

Oh... yes!

If there is one thing you learned along the way that you would tell new developers, what would it be?

Actually listen to your elders, and follow through with what they tell you. At the same time, question everything they tell you, and decide what's right for you.

"Listen to your elders, but question everything they tell you."

What's the most fun you've ever had programming?

The Nothin' But .NET boot camp (times 2)... seriously, it blows my mind!

Who am I calling out?

Luu Duong

Mark Chen

Owen Rogers

Adam Alinauskas (whenever he gets his blog back up)

David Morgantini

So yesterday I had this idea on how to run a background thread using an interceptor, but first I needed to Grok how the castle interceptors worked. I quickly ran into a snag, it looked something like this:


The problem is that the latest version of Rhino.Mocks hasn't internalized the castle dependencies. So the compiler doesn't know whether I'm referring to Castle.Core.Interceptor.IInvocation from the Castle.Core.dll or Castle.Core.Interceptor.IInvocation from Rhino.Mocks.dll.

I'm not sure why this is, so I did a little digging. And found this post... In one of the last comments someone else had this same issue...


I'm not really sure what this meant, so I decided to pull the source from the trunk. In the Rhino.Mocks project there's a file called "ilmerge.exclude" and in it was the interface that I was having trouble resolving (IInvocation). I removed it from the file, and rebuilt a release version. Seems to be working now.... I'm still not sure why this change was made... which makes me feel a bit uneasy.


Try it at your own discretion.

In case you haven't you should read...

xUnit Test Patterns: Refactoring Test Code (The Addison-Wesley Signature Series)
by Gerard Meszaros

Read more about this book...

As a reminder, let's talk about a test smell described in the above mentioned book. It's called "Conditional Test Logic".

"Conditional Test Logic: A test contains code that may or may not be executed." xUnit Test Patterns

"A fully automated test is just code that verifies the behavior or other code. But if this code is complicated, how do we verify that it works properly?"

Warning bells should sound off in your head when you start to see looping or conditional constructs within a single unit test.

"Code that has only a single execution path always executes in exactly the same way. Code that has multiple execution paths presents much greater challenges and does not inspire as much confidence about its outcome."

For more information check this out...

Basically Ignore Logic... that could cause multiple execution paths within a single unit test.

So I got a phone call this morning that went something like this....

"Yo mO, what's happenin' homie?", voice on the phone.

"Ye'.... I'm just slingin some code wit my compadre, G. What's crackin'?", says mo!

"So word on the street is that you're slingin' some made Rhino Mocks 3 dot 5 ish? So lemme asks you, how do you bust out some event raisin' with the new ish?"

My response... "I gots no clue my man, no clue!"

After some quick digging here's what I found... (Please remember this is a contrived example!)

The old school way...

 1   [TestFixture]
 2   public class AnonymousPresenterTest {
 3       private IView view;
 4       private MockRepository mockery;
 5       private ITask task;
 7       [SetUp]
 8       public void SetUp() {
 9           mockery = new MockRepository();
10           view = mockery.DynamicMock<IView>();
11           task = mockery.DynamicMock<ITask>();
12       }
14       public IPresenter CreateSUT() {
15           return new AnonymousPresenter(view, task);
16       }
18       [Test]
19       public void ShouldDoSomethingUseful() {
20           IEventRaiser raiser = null;
21           using (mockery.Record()) {
22               view.Load += null;
23               raiser = LastCall.GetEventRaiser();
25               Expect
26                   .Call(task.AllProvinces())
27                   .Return(new List<IProvince>());
28           }
30           using (mockery.Playback()) {
31               CreateSUT();
32               raiser.Raise(null, EventArgs.Empty);
33           }
34       }
35   }

Here's the new way.. that I quickly Googled for...

 1   [Concern(typeof(AnonymousPresenter))]
 2   public class when_the_view_is_first_loaded : context_spec<IPresenter> {
 3       private IView view;
 4       private ITask task;
 6       protected override IPresenter UnderTheseConditions() {
 7           view = Dependency<IView>();
 8           task = Dependency<ITask>();
 9           return new AnonymousPresenter(view, task);
10       }
12       protected override void BecauseOf() {
13           view.Raise(v => v.Load += null, view, EventArgs.Empty);
14       }
16       [Test]
17       public void should_do_something_useful() {
18           task.should_have_been_asked_to(t => t.AllProvinces());
19       }
20   }

So there you have it. Enjoy..


I found the usage on Ayende's wiki here. Also, I am not a Rhino.Mocks guru, nor do I want to be, and yes the phone conversation was not as interesting as was previously illustrated.

Building a splash screen. (err... not taking a bath)

So one requirement we had this week was to add a splash screen to the project we're working on. My knowledge of threading is weak, so bare with me. As our application started to grow, the start up times started to grow so a splash screen is supposed to be a queue to the user that yes the app is running.

This is what the end result ended up...

1   using (new BackgroundThread(new DisplaySplashScreenCommand()))
2   {
3       ApplicationStartUpTask.ApplicationBegin();
4   }

So what's happening is the Splash screen is loaded on a background thread, while the application start up continues on the main thread. When the application start up is finished, the background thread disposes of the command that it's executing. In this case it starts fading the splash screen away.

Here's the core interface that made this happen.

1   public interface ICommand
2   {
3       void Execute();
4   }
1   public interface IDisposableCommand : ICommand, IDisposable
2   {
3   }
5   public interface IBackgroundThread : IDisposable
6   {
7   }

This is a pretty simple solution (IMHO). The actual splash screen is just a win form, that starts a timer and adjusts the opacity when it's asked to display, then fade away when it's asked to hide.

 1   public partial class SplashScreen : Form, ISplashScreen
 2   {
 3       private Timer timer;
 5       public SplashScreen()
 6       {
 7           InitializeComponent();
 8           Visible = false;
 9       }
11       public void DisplayTheSplashScreen()
12       {
13           ApplyWindowStyles();
14           StartFadingIn();
15       }
17       public void HideTheSplashScreen()
18       {
19           StartFadingOut();
20       }
22       private void StartFadingIn()
23       {
24           Opacity = .0;
25           timer = new Timer {Interval = 50};
26           timer.Tick += ((sender, e) => { if (Opacity < 1) Opacity += .05; });
27           timer.Start();
28           ShowDialog();
29       }
31       private void StartFadingOut()
32       {
33           if(timer != null &amp;&amp; timer.Enabled){
34               timer.Stop();
35           }
36           timer = new Timer {Interval = 50};
37           timer.Tick += (delegate {
38                                  if (Opacity > 0) {
39                                      Opacity -= .1;
40                                  }
41                                  else {
42                                      timer.Stop();
43                                      Close();
44                                  }
45                              });
46           timer.Start();
47       }
49       private void ApplyWindowStyles()
50       {
51           BackgroundImage = Image.FromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "images/splash.jpg"));
52           FormBorderStyle = FormBorderStyle.None;
53           StartPosition = FormStartPosition.CenterScreen;
54           ClientSize = BackgroundImage.Size;
55           TopMost = true;
56       }
57   }

For starting and running a non-blocking background thread, we're using the BackgroundWorker class which takes care of thread synchronization. (This comes in handy for synchronizing UI elements)

 1   public class BackgroundThread : IBackgroundThread
 2   {
 3       private readonly BackgroundWorker worker_thread;
 5       public BackgroundThread(IDisposableCommand command)
 6       {
 7           worker_thread = new BackgroundWorker();
 8           worker_thread.DoWork += delegate { command.Execute(); };
 9           worker_thread.Disposed += delegate { command.Dispose(); };
10           worker_thread.RunWorkerAsync();
11       }
13       public void Dispose()
14       {
15           worker_thread.Dispose();
16       }
17   }

Just so you get the rest of the code, here's the DisplaySplashScreenCommand, although I'm sure it was obvious.

 1   public class DisplaySplashScreenCommand : IDisposableCommand
 2   {
 3       private ISplashScreen splash_screen;
 5       public DisplaySplashScreenCommand() : this(new SplashScreen())
 6       {
 7       }
 9       public DisplaySplashScreenCommand(ISplashScreen splash_screen)
10       {
11           this.splash_screen = splash_screen;
12       }
14       public void Execute()
15       {
16           splash_screen.DisplayTheSplashScreen();
17       }
19       public void Dispose()
20       {
21           splash_screen.HideTheSplashScreen();
22       }
23   }

Hope this helps anyone out there trying to implement a splash screen. PS. I can't stress the fact that my knowledge of Threading is limited, so if you know of a cleaner implementation... Please, please hook a brotha up!

The end result looks like...


Tonight I finished reading...

C# in Depth: What you need to master C# 2 and 3
by Jon Skeet

Read more about this book...

This was an amazing book, and definitely offers a great in depth look at the C# language. Most importantly it answered a lot of my questions about elements introduced in C# 3.0, and taught me things I didn't know about C# 1.0. If you're looking for information on the following items, then this book is definitely for you.

  • Expression
  • IQueryable
  • IQueryProvider
  • Lamba's
  • Type Inferencing

Thanks JP for recommending this book!

Here are a few gems that I picked from this book.


"You rarely see an explicit call to Delegate.Combine in C# code - usually the + and += operators are used."

1   var x = new EventHandler(delegate { });
2   var y = new EventHandler(delegate { });
3   x += y;
4   x = x + y;// same as above
5   x = (EventHandler) Delegate.Combine(x, y);// same as above

Static vs Dynamic Typing

"C# is statically typed: each variable is of a particular type, and that type is known at compile time. The alternate to static typing is dynamic typing, which can take a variety of guises. "

Explicit vs. Implicit Typing

"The distinction between explicit typing and implicit typing is only relevant in statically typed languages. With explicitly typing, the type of every variable must be explicitly stated in the declaration. Implicit typing allows the compiler to infer the type of the variable based on its use."

Covariant vs. Incovariant

1   object[] stuff = new string[]{"blah"}; // valid and is an example of covariance
2   List<object> more_stuff = new List<string>();// invalid and is an example of incovariance

Fluent Interfaces

Jon, the author, mentions a blog post by Anders Noras on Planning a fluent interface

Here's an example of a fluent interface for building menu's that I've been playing with.

1   CreateA.MenuItem()
2     .Named("&amp;Close")
3     .BelongsTo(MenuGroups.File)
4     .CanBeClickedWhen(m => task.IsThereAProtocolSelected())
5     .WhenClickedExecute(closeCommand)
6     .Build();


"When it comes to getting the broad sweep of code, what is required is 'readability of results' - I want to know what the code does, but I don't care how it does it right now."

There's a lot of information on IQueryables, Expression Trees, and other goodness in this book. This is a great book and definitely worth reading, especially if you're as interested in the C# language as I am.

I mean Grokking Rhino Mocks. My usage of Rhino Mocks has changed quite a bit since I first started using it a year ago, as well as the way I write tests.

First it was like this:

 1   [TestFixture]
 2   public class ConsoleTest {
 3       private MockRepository mockery;
 4       private IReportPresenter presenter;
 6       [SetUp]
 7       public void SetUp() {
 8           mockery = new MockRepository();
 9           presenter = mockery.CreateMock<IReportPresenter>();
10       }
12       [TearDown]
13       public void TearDown() {
14           mockery.VerifyAll();
15       }
17       [Test]
18       public void ShouldInitializeTheReportPresenter() {
19           var commandLineArguments = new[] {"blah"};
20           presenter.Initialize();
22           mockery.ReplayAll();
23           new Console(presenter).Execute(commandLineArguments);
24       }
25   }

Then it evolved to this...

 1   [TestFixture]
 2   public class ConsoleTest {
 3       private MockRepository mockery;
 4       private IReportPresenter presenter;
 6       [SetUp]
 7       public void SetUp() {
 8           mockery = new MockRepository();
 9           presenter = mockery.DynamicMock<IReportPresenter>();
10       }
12       [Test]
13       public void ShouldInitializeTheReportPresenter() {
14           var commandLineArguments = new[] {"blah"};
16           using (mockery.Record()) {
17               presenter.Initialize();
18           }
19           using (mockery.Playback()) {
20               CreateSUT().Execute(commandLineArguments);
21           }
22       }
24       private IConsole CreateSUT() {
25           return new Console(presenter);
26       }
27   }

Then for a short time I tried this...

 1   [TestFixture]
 2   public class when_giving_the_console_valid_arguments {
 3       private IReportPresenter presenter;
 5       [SetUp]
 6       public void SetUp() {
 7           presenter = MockRepository.GenerateMock<IReportPresenter>();
 8       }
10       [Test]
11       public void should_initialize_the_report_presenter() {
12           var commandLineArguments = new[] {"blah"};
13           CreateSUT().Execute(commandLineArguments);
14           presenter.AssertWasCalled(p => p.Initialize());
15       }
17       private IConsole CreateSUT() {
18           return new Console(presenter);
19       }
20   }

Now I'm trying this...

 1   [Concern(typeof (Console))]
 2   public class when_the_console_is_given_valid_console_arguments : context_spec<IConsole> {
 3       private string[] command_line_arguments;
 4       private IReportPresenter presenter;
 6       protected override IConsole UnderTheseConditions() {
 7           command_line_arguments = new[] {"path", "testfixtureattributename"};
 8           presenter = Dependency<IReportPresenter>();
10           return new Console(presenter);
11       }
13       protected override void BecauseOf() {
14           sut.Execute(command_line_arguments);
15       }
17       [Test]
18       public void should_initialize_the_report_presenter() {
19           presenter.should_have_been_asked_to(p => p.Initialize());
20       }
21   }

Now I'm generating reports from my tests specs using this. I wonder what's next...

Last week I finished reading...

The 7 Habits of Highly Effective People
by Stephen R. Covey

Read more about this book...

I really enjoyed this book, it's definitely worth taking the time to sit down and read. I realized a lot about myself as I read it. Hopefully you will too! Here are a few excerpts from the book that had an impact on me.

"Management is a bottom line focus: How can I best accomplish certain things? Leadership deals with the top line: What are the things I want to accomplish?"

"... envision a group of producers cutting their way through the jungle with machetes. They're the producers, the problem solvers. They're cutting through the undergrowth, clearing it out.

The managers are behind them, sharpening their machetes, writing policy and procedure manuals, holding muscle development programs, bringing in improved technologies and setting up working schedules and compensation programs for machete wielders.

The leader is the one who climbs the tallest tree, surveys the entire situation, and yells, 'Wrong Jungle!'"

"Work Centeredness. Work-centered people may become 'workaholics,' driving themselves to produce at the sacrifice of health, relationships, and other important areas of their lives. Their fundamental identity comes from their work - 'I'm a doctor', 'I'm a writer', 'I'm an actor.'

Because their identity and sense of self-worth are wrapped up in their work, their security is vulnerable to anything that happens to prevent them from continuing in it. Their guidance is a function of the demands of the work. Their wisdom and power come in the limited areas of their work, rendering them ineffective in other areas of life."

"There are times when neither the teacher nor the student knows for sure what's going to happen. In the beginning, there's a safe environment that enables people to be really open and to learn and to listen to each other's ideas. Then comes brainstorming, where the spirit of evaluation is subordinated to the spirit of creativity, imagining, and intellectual networking. Then an absolutely unusual phenomenon begins to take place. The entire class is transformed with the excitement of a new thrust, a new idea, a new direction that's hard to define, yet it's almost palpable to the people involved."

"Suppose you were to come upon someone in the woods working feverishly to saw down a tree.

'What are you doing?' you ask.

'Can't you see?' comes the impatient reply. 'I'm sawing down this tree.'

'You look exhausted!' you exclaim. 'How long have you been at it?'

'Over five hours,' he returns, 'and I'm beat! This is hard work.'

'Well, why don't you take a break for a few minutes and sharpen that saw?' you inquire. 'I'm sure it would go a lot faster.'

'I don't have time to sharpen the saw,' then man says emphatically. 'I'm too busy sawing!'"

"Principles are natural laws that are external to us and that ultimately control the consequences of our actions. Values are internal and subjective and represent that which we feel strongest about in guiding our behavior."