Wednesday, June 29, 2011

Announcing C# TDD Course in Houston

UPDATE: Rescheduled to August 19

I'm offering a one-day pilot course on Test Driven Development and Design in C# on Friday, July 29 Aug 19, 2011 in Houston, Texas.  The cost is $128 for the day (9 - 5).  The class will be limited to 15 students.  The location will be announced.  It is likely to be in the Westchase area.

The class focuses on unit testing and test first design.  We will discuss foundational principles and go through hands-on labs.  We will discuss your concerns about TDD and how to realize its benefits.

Introduction to TDD with C#
  • Benefits and Goals
  • Concerns and Fears
  • Principles and Practices
  • Accelerators (tailored to Microsoft Visual Studio)
About the Instructor
I've gone from unit testing skeptic to TDD evangelist.  I love coding.  I love sharing what makes coding more rewarding!  I've been developing using TDD with C# for three years.  I've been programming since before I could drive...

Get in Touch
If you have questions about the course feel free to post a comment below.  Or contact me on Twitter or LinkedIn.  Registration for the class is handled through PayPal by clicking the button below.


Recommendations
You will enjoy this class if you are a C# developer who wants to:
  • Regain the joy of programming
  • Feel relaxed and focused, even in the face of changing requirements
  • Avoid maintaining complex Rube Goldberg systems
  • Be more confident in your code
Students should bring their own machine with Visual Studio.  The classroom will have WiFi and power at each station.  Lunch will not be provided.

Why Hulu's Device Segmentation is Backwards

Open up Hulu on your iPhone and you don't watch video.  Instead, you see a message:
To watch videos on this iPhone, please subscribe to Hulu Plus.
They are segmenting their market by device.  But, they've got their market segmentation backwards.

What drives companies to try market segmentation is the idea that you can maximize profit by charging more to customers who are willing to pay more.  Joel Spolsky explained it well in his article "Camels and Rubber Duckies".

Hulu has it backwards because they are trying to maximize profit on small, wireless handheld devices, rather than on big-screen home theaters.  Phones are becoming the common way to view online content.  Phones are the horizontal.  Big screens are the vertical.

They also have it backwards because people will pay more when they can combine viewing with eating, drinking and socializing.  (Why do people still go to the movies if everyone complains about how expensive they are?)

Ever try to eat dinner while watching a video on your iPhone?  Ever try to share that show with the person sitting next to you?  Suddenly the 1950's experience of having dinner and enjoying a show with your family becomes a feature worth paying for (again).  I suspect the big networks (the ones behind Hulu) take this TV experience for granted.

Eventually Hulu will figure this out and try to flip it.  But, they won't be able to without losing customers.  People are sensitive to artificial segmentation.  People will realize that this segmentation is contrived and will entertain getting their entertainment elsewhere.

Sunday, June 26, 2011

Quick Example using TestDrivenDesign

using TestDrivenDesign;

[TestClass]
public class QuickExampleTest : TestBase<QuickExample>
{
    [TestMethod]
    public void ShouldSayHelloMultipleTimes()
    {
        // Arrange
        Subject.Count = 3;      
        // TestBase<T> provides us with a default constructed
        // QuickExample (think: "Test Subject")
        var path = TextPath();
        // Gives us a path in the test run directory like: 
        // QuickExampleTest.ShouldSayHelloMultipleTimes.txt

        // Act
        Subject.SayHello(path);

        // Assert
        TestContext.AddResultFile(path);
        // TestBase provides the TestContext property. 
        // AddResultFile adds a hyperlink to our file on the
        // test result page
        TextFileAssert.Contains(path, "hello hello hello");
        // TextFileAssert helps test writing text files.
        // Yes, there is a BinaryFileAssert too!
    }
}

Let's take a moment to review the code that you aren't writing:
  • No TestContext boilerplate
  • No initialization of your test subject. Every test method gets a newly constructed subject, which you are free to overwrite
  • No coming up with your own unique file name and combining it with the deployment directory
  • No reading of a text file into a string or collection before you can do an assert
This was also posted on the TestDrivenDesign wiki.  Get the code at https://github.com/jfoshee/TestDrivenDesign

Friday, June 24, 2011

I Picked the MIT License for TestDrivenDesign

Today I elected to release TestDrivenDesign under the MIT License.

Why the MIT License?

  • I want to make other developers smile
  • I believe in an Abundance Mentality

As a developer, when I use open source code, the MIT License always makes me smile. So, hopefully this will make other developers happy.

A scarcity mentality would have me keep my code hidden from the world, and retain as many rights as possible.  But, I believe in fostering an Abundance Mentality.  I believe that "my cup runneth over" is not just an observation; it is a mindset.

Wednesday, June 22, 2011

Using TestDrivenDesign

Announcing the TestDrivenDesign C# library on Github: http://github.com/jfoshee/TestDrivenDesign

Over the past few years I have become an advocate of Test Driven Development and Test Driven Design (TDD).

I've done most of my unit testing in C# using the Visual Studio unit testing framework.  So, I've started to factor out common patterns from my tests into this library.

The name of this library may seem a bit presumptuous.  But, I thought it was appropriate since I want to see more code:
using TestDrivenDesign;

Friday, June 3, 2011

Two-person Canoeing takes Teamwork

or "How Ears Trump Oars"

Last weekend I went canoeing with several friends.  Alejandra and I teamed up in one canoe.  We took it as an opportunity to work on our own teamwork.  I am proud to say that we did well, but it was a challenge!

When you put two people in one canoe with one destination, you have created an effective illustration of Interdependence.  (I am using the term as Covey does in The 7 Habits of Highly Effective People, which I reference often.)

The two people have to work as a team to reach their goal.  But, what does it mean to work as a team?

Each Independent
Often people think of teamwork as breaking a big task into several non-overlapping (independent) tasks.  This is the simplest functioning form of cooperation. It is what we learn to do on school projects.  "I'll write the report and you find the pictures and build the poster board."

In a canoe it is almost impossible to create non-overlapping roles.  As soon as you put an oar in the water you are affecting the direction of the boat.  That's a good thing.

Most professionals have achieved some basic independence.  And most professionals are comfortable dividing work this way: where there is as little coordination as possible.  Sometimes it goes to the point of silly imbalance... "I'll watch for sharks while you paddle."

This independence can render the team totally ineffective.  Try paddling upstream.  If you are taking turns paddling, for example, you are going to move slowly (if at all) and both be exhausted.

Finally, in the worst case, both people work against each other.  "I'm just going to paddle my hardest to get this thing moving regardless of what the other guy is doing."  Believe it or not, it takes some effort to flip a canoe.  But two inconsiderate teammates can certainly make it happen.

Compromise
With some basic instructions most people will divide the work this way: the person in back steers the boat, and the person in front makes it go forward.  This is an effective system for two people to navigate a canoe downstream.  But, it is not optimal.

Here's why: You can't paddle on one side of the boat without affecting it's direction.

So, if the person in front is only trying to provide power without concern for direction, the person in back is going to have to compensate.  With every stroke that the front person makes, the person in back is going to have to apply a counter-stroke to keep the boat on course.

The person in back is using their energy to undo part of what the person in front did.  Not optimal.

The boat zigs and zags...  The person in back is frustrated because someone else is making their job harder.  The person in front is frustrated seeing that they are paddling towards the shore and not downstream.  Energy is wasted and frustration builds.

Coordination and Synergy
When people become frustrated with each other the first thing to go is communication.  But communication is absolutely necessary to coordinate.  And coordination is necessary for synergy (and to paddle a canoe efficiently).

When the two shipmates are communicating, they can issue requests to each other.
"I need you to switch sides so we can make this turn."
"Shallow water 10 yards ahead!"
"Should we go to the left or right of this branch?"
"Give me two good strokes!  All your might!  We can get over this log!"
"Great job!  Let's take a break."

It's good to be comfortable to issue requests to each other.  But it is more important to be listening and responding to the requests.

Now both people can be paddling.  The rear person may be more responsible for steering and the front person more responsible for power, but they recognize the overlap.  They embrace the overlap.  They are working together.

Now they can make sharp turns.  Now they can go upstream.  And now they can overcome obstacles.

Advice
1. Use your oar
Remember that you have no one to blame but yourself.  As Dan pointed out, "You each have an oar."

2. Use your ears
When we started our trip, some of our friends were making their way downstream leaving us behind.  This gave us a sense of urgency!  "We better get moving.  They are getting far ahead."  But this sense of urgency is dangerous.  It gives the illusion that starting to paddle is more important than working out the skills that will be necessary for the trip.  Don't give in to imagined crises.

Before you start trying to make progress down river, take the time to discuss roles and goals.  Throughout the trip make special effort to listen to your teammate.