Tuesday, January 31, 2012

Luncht v.3 - Password Reset

Not sure if we will get to this feature tonight but I'll try to keep one step ahead of our sessions so we are not wondering what is next.

Password Maintenance

As a user I need to be able to reset my password if I've forgotten what it is or whenever I would like to change it.

  • Key Is Created for forgotten Password
    A key needs to be created that will be sent to the user in the form of a link.
  • Key and New Password Required for Reset
    If key does not match we will error out.
  • New Password Will Be Encrypted
    We never want to see the password so the new one will be encrypted.
  • Email and New Password Will Validate User
    If Email and New Password match the user will be valid.
  • If User is Validated Password Can Change Without Key
    If the user is logged in the key is not required for password reset.

I think this is doable in one session. If not it's not a big deal.

Monday, January 30, 2012

Luncht v.3 - Session One - Chadrick's Take

I want to start by thanking Brian for trying TDD & PPP. I knew he had (maybe "has") a tendancy to shy away from pairing and I appreciate his openness to try it.

I also want to thank Dan Tape for throwing out the suggestion that we try Google Hangout for our dev sessions. As far as I'm concerned it's as good, and perhaps better than real life. Now we can base our showering habits wholly on our wives desires to be around us. if you have not tried Hangouts, do it and save some soap.

I had pre-written a feature called 'Registration' with a few bullets of acceptance tests to start with. I was basically following our precompiler format. Then because we are both familiar and fans of Pivotal Tracker I converted that item to a story with tasks for each of the acceptance tests.

Registration

As a user I need to be able to register for a new account so that I can use the system.

  • Required Property FirstName
    User needs to have a FirstName property and it is required.
  • Required Property LastName
    User needs to have a LastName property and it is required.
  • Required Field Email
    User needs to have a Email property and it is required.
  • Required Field Password
    Password field is encrypted once set.
  • Password Field Needs to be Encrypted
    User needs to have a FirstName property and it is required.
  • Default Chat Notifications
    During registration users are will be signed up to receive chat notifications.
  • Default Deal Notifications
    During registration users are will be signed up to receive deal notifications

When we opened Visual Studio we started with a class library project and loaded NUnit and Moq with Nuget. We had one test at first with all the fields in it, but later refactored it so that each prop had its own test.

[TestFixture(Description = "As a user I need to be able to register for a new account so that I can use the system.")]
public class Registration
{
    [Test(Description = "User needs to have a FirstName property and it is required.")]
    public void RequiredPropertyFirstName()
    {
        // Arrange & Act
        const string firstName = "blah1";
        var user = new User( );
        user.FirstName = firstName;

        // Assert
        Assert.AreEqual(firstName, user.FirstName);
    }

    [Test(Description = "User needs to have a LastName property and it is required.")]
    public void RequiredPropertyLastName()
    {
        // Arrange & Act
        const string lastName = "blah2";
        var user = new User( );
        user.LastName = lastName;

        // Assert
        Assert.AreEqual(lastName, user.LastName);
    }
}

As you can see I've started putting the text inside of Description of the Test. I have an idea for a code generator that would build these tests out with an [Ignore] attribute on them. I might write about this in a future post. But as you can see we build our tests based on the required acceptance tests. Understand properties are not the sexiest of tests to write and perhaps a bit overkill, but it's TDD and we are 100% sure when done means done.

For most of this session we just did domain object tests. They were very basic and that allowed us to practice the Red >> Green >> Refactor Ping Pong Pairing workflow. For those of you who don't know what that is I'll give a quick run-through.


  1. I start by writing a failing test. We decided our code had to compile so we had to create what was necessary for that to happen. I pushed the code to BitBucket for Brian.
  2. He implemented the code to make the test pass and then checked it into HG and pushed it back to BitBucket.
  3. We talked through things if necessary and refactored it accordingly.
  4. Now it was his turn to write the failing test, so we jumped down to the next bullet.
  5. I implement...
  6. He refactors...
  7. ...repeat

I was happy how it went. I'll let Brian give his own take on it.

Sunday, January 29, 2012

TDD and Ping Pong Pairing

At CodeMash I attended the precompiler event, 'Putting the D&D Back Into TDD' by Guy Royse (@guyroyse) and George Walters II (@walterg2). Now I'm an old school D&D player at heart so this abstract was right up my ally.
Abstract: Are you tired of TDD workshops that make you do boring things like calculate bowling scores and prime factors or demonstrate how to win at the game of life? If so, this is the session for you! In this TDD workshop we will be building the domain model for EverCraft -- a new MMORPG from Blizzards of the Coast. We have lots of story cards prepared covering features from combat to magic, classes to spells, and races to items. Plus, we'll be defining some of these cards during the session in case you want that +9 knife of ogre slaying or enjoy casting magic missile at the darkness. This workshop is language agnotisic and for all levels of developers. The focus is on TDD and emergent design but pair programming will be covered as well. The only requirement is that you bring a laptop and that you be able to test-drive you code with your language of choice. When you are done you will emerge a better programmer for the experience but there is small chance you will have a craving for Cheetos and Mountain Dew.
Early in the session George said something that had a huge part in the development of this blog. While talking about agile practices and paired programming in particular he said, "Let's be honest, programming alone is scary." I laughed a little and then the thought kept coming back to me throughout the day and ever since.
"Let's be honest, programming alone is scary."

                                                                            ~ George Walters II
As promised we were given a sheet of features then instructed to team up with another dev who was using the same language. Then we started. The workflow was simple. One of us would write a failing test, the other would implement the code to make the test pass, and then the first dev would refactor the implemented code.

At first we were unsure of ourselves and decided that maybe we knew better. We would take and write two tests; one each. Then we would switch and implement the other's test at the same time. Then we would refactor together and this seemed to work out alright for us. After our first iteration we had a retrospective and talked about our workflow. Guy and George talked us into doing it the more purer way, so after lunch we did and realized some major benefits.

Benefits of TDD & Ping Pong Pairing:

  1. Focusing on the acceptance test stopped me from over designing the solution.
  2. Writing the failing test makes you think about how you would like to use a class and its methods.
  3. Implementing code to make the test pass kept me focused on the test at hand vs. stuff we are probably not going to need. YAGNI
  4. Watching each other program and discussing the problems together helped each of us learn.
  5. We both had intimate knowledge of the codebase when we were done.
  6. Working on things together kept us from becoming distracted by outside influences (email, phone calls, day dreaming etc). We continued to code for almost 8 hours with only a few breaks.
  7. We knew when we were done with our feature.
Something that I came away with is that Test Driven Development is less about testing and more about designing. I watched a video about TDD that used the analogy of tests being like a carpenter's jig for the woodworker. There is a difference in that the developer only writes his/her test right before coding it while the carpenter starts with a complete jig.

This event motivated me to get back into Luncht with Brian. We have been using Google Hangouts to do our ping pong pairing and have done three sessions so far. It's been very cool learning the workflow together and I'm hoping that we will be writing more about this as life permits.

Saturday, January 28, 2012

Hi, I'm Chadrick and I'm a...

...developer. When I first understood that I could press my fingers to the keyboard and build content of some kind something happened within me. I felt like I was tapping into some secret ancient arcane power. I could summon things to the screen if I knew the right words to type. I could make things happen faster than the speed of thought. Its hold on me grew more and more. I would spend countless hours in a small room lit only by a monitor, learning and coding anything and everything I could. The more I learned, the more I believed anything was possible. If I could imagine it, I could produce it; or at least the potential to produce it was a real possibility. Now marry that to the fact that I've always been an ideas person and you can start to see that I had a real problem. In order to help me understand my addiction I had to find other practitioners of these arts. It was hard back then because I wasn't going to school for it or working in it full time, but we found each other. I learned that we spoke the same language, squinted at the sun in the same way when we had to be out in it, and tended to do our own things our own ways. To save my marriage I had to get paid for my addiction and then things started to change. I had to learn what it was like to go into business with someone who promised me one thing for doing what I loved and then gave me something else. After that experience I joined corporate IT and had to mature even more. I had to learn about this thing called source control, and there were these people called Business Analysts, and these documents called Specifications Documents and the ever present DEAD-LINE and other developers who freaked me out because they obviously knew more than I did. Around this time I came across a book called, Extreme Program Explained: Embrace Change. WOW! If I could only get my co-workers and managers to understand the benefits of what was in this book our lives would be forever changed for the better. At the time my influence didn't go real far, but I kept at it. Gradually the people started to see what I had seen. I became someone with a bit more influence and we all started to hear the word Agile more and more. A few years and companies later; I'm still not doing extreme programming everyday but I'm starting to practice some of those extreme practices I'd only read about, and others are doing it as well. I'm hoping we can write about our adventures and bring something helpful to the table. Here is to hope.

Tuesday, January 17, 2012

CodeMash 2012 - Special Thanks

Thanks to my blog co-author Brian I was introduced to Christiaan Baes from Less Then Dot who was running a little competition. Because of that fateful link, a few sad words, a new boss, a supportive wife and the generosity of chrissie1 I attended CodeMash for the first time this year. Thanks to you all.
CodeMash is a unique event that will educate developers on current practices, methodologies and technology trends in variety of platforms and development languages such as Java, .NET, Ruby and PHP.