About Me

Training

Nothin But .Net Developer Bootcamp

Navigation

Search

Categories

On this page

Look Ma' More Displays!!
Get Your Learning On!!
Don't play limbo with your goals
BDD AutoHotKey Script Update - Take 2
Regarding Passion!!
BDD AutoHotKey Script Update - Take 1
Nothin But .Net Vancouver - Now Being Held@Empire Landmark Hotel
So Long BDD Macro - Hello Autohotkey!!!
Another course completes, another update to the BDD Macro!!
Toronto Recap
ReSharper 4.0 Beta
Small Update to BDD Macro
Solution Reorganizing (Again!!)
Slightly Different Way To Assert That Exceptions Are Thrown
Just For Clarification re The Latest DotNetRocks Episode
Amazon Giveaway Over - 3 days later!!
Nothin But .Net - Vancouver, BC (June 23rd - 27th) @ The Empire Landmark Hotel
Do You Want $70 To Spend On Amazon?
Are You Interested In Setting Up Your Own Training Company?
What Do I Get From It?
Got Icons?
Got A Spotter?

Archive

Blogroll

 Agile Developer Venkat's Blog
 Ayende @ Blog
 B#
 Barry Gervin's Software Architecture Perspectives
 Boy Meets World
 Brad Abrams
 Canadian Developers
 Christopher Steen
 Claritude Software News
 Clemens Vasters: Enterprise Development and Alien Abductions
 Coding Horror
 Coding in an Igloo
 Dare Obasanjo aka Carnage4Life
 Darrell Norton's Blog [MVP]
 David Hayden [MVP C#]
 Don Box's Spoutlet
 Eric Gunnerson's C# Compendium
 EZWeb guy: Jeffrey Palermo [C# MVP]
 Fear and Loathing
 Generalities & Details: Adventures in the High-tech Underbelly
 Greg Young [MVP]
 Greg's Cool [Insert Clever Name] of the Day
 IanG on Tap
 Ingo Rammer's Weblog
 ISerializable - Roy Osherove's Blog
 James Kovacs' Weblog
 Jason Haley
 Jean-Luc David
 Jeremy D. Miller -- The Shade Tree Developer
 JetBrains .NET Tools Blog
 Jimmy Nilsson's weblog
 John Bristowe's Weblog
 John Papa [MVP C#]
 Jon Skeet's Coding Blog
 JonGalloway.ToString()
 Jump the Fence or Walk Around
 Lambda the Ultimate - Programming Languages Weblog
 Larkware News
 Lutz Roeder
 Marquee de Sells: Chris's insight outlet
 Martin Fowler's Bliki
 Mike Nichols - SonOfNun Technology
 MSDN Magazine - .NET Matters
 MSDN Magazine - All Articles
 OdeToCode Blogs
 Onion Blog
 Planet TW
 Raymond Lewallen [MVP]
 Rockford Lhotka
 RodMan's Corner
 Roger Johansson's blog
 Sahil Malik - blah.winsmarts.com
 Sam Gentile's Blog
 Scott Bellware [MVP]
 Scott Hanselman's Computer Zen
 ScottGu's Blog
 secretGeek
 Service Station, by Aaron Skonnard
 Signum sine tinnitu--by Guy Kawasaki
 Stephen Toub
 Steve Eichert's Blog
 Steven Rockarts
 The Blog Ride
 The Coding Hillbilly
 The Daily WTF
 TheServerSide.net: News
 Tim Gifford
 Vance Morrison's Weblog
 you've been HAACKED

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 397
This Year: 122
This Month: 0
This Week: 0
Comments: 1033

 Friday, May 30, 2008
Friday, May 30, 2008 9:47:41 PM (Mountain Standard Time, UTC-07:00) ( Tools )

VMWare Fusion 2.0 Beta just released and they finally have support for something I have been missing for a while since switching to the wonderful world of WOM (Windows On Mac), multi-monitor support.

Finally I can run my VM and stretch it across an many displays as my mac can physically handle!!! Now realistically, for me that just means my Monitor and the MacBook Pro LCD, but it is still better than nothing!!

Check out more information here: http://blogs.vmware.com/teamfusion/2008/05/more-displays-m.html

Comments [0] | | # 
Friday, May 30, 2008 6:12:35 AM (Mountain Standard Time, UTC-07:00) ( Training )

In order to post this out there publicly so that more people can potentially benefit from it, this post contains a set of materials that I use to prepare people who come and attend a Nothin But .Net bootcamp. The materials are as follows:

  • developer.tools.list.doc - A list of a lot of good tools that I use on a daily basis.. One of the first things I do in this list is to draw attention to the tool compendium to end them all.
  • developer reading.list.doc - A list of good reading material/exercises that can help get people ramped up with their fundamental developer skillset. Some of the resources that I link to are MIT opencouseware, books, and CodeKata's.
  • public.course.preparation.doc - If you don't ever plan on attending a Nothin But .Net bootcamp, you can skip most of the information in the document. Although, the bottom of the document contains a small OO problem that I use as a way to gauge where peoples OO thinking is at.

Instead of getting overwhelmed in the sea of information that is floating around you, you can choose to get in your boat and chart your own path for continuous, maintainable learning that can fuel you for the duration of your career. I feel that some of the resources in the documents above can give you the tools to potentially help you get started on this journey.

Develop With Passion!!

Comments [4] | | # 
 Wednesday, May 28, 2008
Wednesday, May 28, 2008 12:46:34 PM (Mountain Standard Time, UTC-07:00) ( Insipration )

The last 2 years I have been blessed beyond measure with the ability to travel around the world with my family doing exactly what I love doing, writing and teaching software development.

Having had the opportunity to share with over 200 developers now in very personal settings, a couple of themes have begun to emerge and there are patterns that I see in the choices that I see people making/not making with respects to their goals for their lives and careers.

I have always had a very cavalier attitude toward my job. And it has been simply this: If I am not enjoying the place that I am currently engaged, and I have done everything in my power to impact change for the betterment of the work environment that I am in, it is time for me to leave.  I do not have time to waste being in a place where I do not feel challenged and happy about the work that I am doing. Develop with Passion is not just a cheesy saying, it is the way I have lived my development career out.

This has always been my approach to maintaining a career where I always feel good about waking up in the morning to go to work. I learned early on that playing limbo with the goals my family and I had set was a slippery slope that can sometimes be hard to bounce back from. Several years ago, I was in a job with a great company. Awesome family atmosphere, lots of projects to work on, relaxed work environment. I had gotten to a point where I was feeling fairly comfortable and not overly challenged. I had a very open supervisor who I shared my concerns with, and I basically ended up giving my notice before I had any other jobs lined up. Keep in mind, that at the time, we had 2 kids and one on the way shortly. My wife and I have always shared the belief that God does not want us in a place where we feel comfortable; and it is in those places where we feel a little uneasy that the potential for big growth can occur. I decided to throw myself out there and see what God presented to us!! It was one of the best decisions I could have made.

What is my point to this little story? So many people I meet daily have not sat down with themselves/their families and set out goals that they can use as a filter to enable them to make decisions that will ultimately affect all facets of their lives. My wife and I sat down and set goals with each other almost immediately after we were married. That initial list was instrumental to us making a lot of decisions early on that would set the stage for the coming years of our marriage and my career.

We had set the bar high on what we wanted to achieve. Looking around at our situation at the time would have given us no reason to set the goals to the level that we had. We just realized that we were not doing ourselves any justice if we set the bar too low for what we wanted to achieve. Some of the largest hurdles you will have to overcome are the ones you will put up for yourself in your own mind. When you sit down and start "dreaming big" just let go and see what you come up with, you may surprise yourself.

Whenever I made/make decisions with regards to contracts I am going to get engaged with, people I am going to get involved with; I always make sure that no interaction that results will cause me to lower my own bar with regards to the quality standards that I have chosen, and the goals I am currently striving after. This makes me very particular about the projects and people I get involved with, but every interaction that I have is meaningful and beneficial.

Instead of constantly lowering the bar with the goals you have set for yourself, it is time to reevaluate the goals you are striving for and work towards making the, sometimes, tough decisions to achieve the goals you have. Most of all, make sure that you have patience to attain that end goal. The Israelites waited in the desert for 40 years until God handed the promise land to them!! Try not to buy into the current MicroWave Culture, where results are manifested without any effort involved on our part!! Anything worth having should not come easy, you should need to work for things to make them a reality.

I am going to encourage you to sit down with your family/significant other tonight and take the time to evaluate the goals your are currently pursuing and seeing if the decisions and potential concessions you are currently making will help you achieve those goals.

If you are reading this and you realize that you have just been 'coasting' I am going to stress the importance of the simple act of writing down a set of goals. This could potentially be a page turning day when you sit down to really question what is important to your life and career and how you are going to work towards making these goals a reality.

As one of my past students so aptly put: "The destination is the journey"!!

Live and Develop with Passion!!

Comments [7] | | # 
Wednesday, May 28, 2008 10:56:54 AM (Mountain Standard Time, UTC-07:00) ( Tools )

I think I now have a version of the script that I love. With some additions made by Aaron Jensen the script now watches for whenever the Enter/Escape key are pressed. Whenever those keys are pressed test naming style will turn off until it is reenabled again. I also modified the script so that when you are in test naming mode and you hit enter/escape it will disable that mode as well as send the keystroke (this is handy when you are in a dialog box, you enable the script, type in the natural name of the class/field,etc and hit enter. Without the modification you will have to hit enter twice!!

Aaron also made a tweak to ensure that the script is only live when VS is active. I find myself using this all over the place, so my version of the script omits that check.

Here is the new version of the script:

;=======================================================================================
;BDD Test Naming Mode AHK Script
;
;Description:
;  Replaces spaces with underscores while typing, to help with writing BDD test names.
;  Toggle on and off with Ctrl + Shift + U.
;=======================================================================================

;==========================
;Initialise
;==========================
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

enabledIcon := "testnamingmode_16.ico"
disabledIcon := "testnamingmode_disabled_16.ico"
IsInTestNamingMode := false
SetTestNamingMode(false)

;==========================
;Functions
;==========================
SetTestNamingMode(toActive) {
  local iconFile := toActive ? enabledIcon : disabledIcon
  local state := toActive ? "ON" : "OFF"

  IsInTestNamingMode := toActive
  Menu, Tray, Icon, %iconFile%,
  Menu, Tray, Tip, Test naming mode is %state% 

  Send {Shift Up}
}

;==========================
;Test Mode toggle
;==========================
^+u::
  SetTestNamingMode(!IsInTestNamingMode)
return

;==========================
;Handle Enter press
;==========================
$Enter::
  if (IsInTestNamingMode){
    SetTestNamingMode(!IsInTestNamingMode)
  }
  Send, {Enter}
return

;==========================
;Handle Escape press
;==========================
$Escape::
  if (IsInTestNamingMode){
    SetTestNamingMode(!IsInTestNamingMode)
  }
  Send, {Escape}
return

;==========================
;Handle SPACE press
;==========================
$Space::
  if (IsInTestNamingMode) {
    Send, _
  } else {
    Send, {Space}
  }

Having used this for the past 2 days now, I am convinced that AHK is the way to go to allow for much more fluidity when trying to write your tests in a more natural english style.

Develop With Passion!!

Comments [1] | | # 
Wednesday, May 28, 2008 9:07:19 AM (Mountain Standard Time, UTC-07:00) ( Insipration )

Stephen McMahon sent me a link to an awesome set of short videos by a man named James Ray. This guy seems to share a lot of the ideas and approaches that have brought me success to this point in my career.

If you ignore the infomercial type feel of the video, I am sure that you will enjoy the message that he is trying to share. I particularly love the story about the shoe shiner, err I mean "image consultant"!!

Watching this video reminds me of something that my Dad said to me a long time ago:

"I don't care if you choose to be a garbageman, you will do it to the best of your abilities and you will enjoy it!!"

Develop With Passion!!

Comments [0] | | # 
Wednesday, May 28, 2008 3:45:44 AM (Mountain Standard Time, UTC-07:00) ( Tools )

Hot on the heels of my announcement about switching to use AutoHotKey, Dave posts an example overhaul that demonstrates just how powerful autohotkey is!! My brain is definitely brimming with ideas on how I can leverage this new tool in the toolbox!!

He has created a script that allows you to toggle BDD naming on/off with the same key sequence. The script also adds a customized tray icon which shows whether the script is currently enabled or not!! This is much better than mine, as you only have to use one keyboard shortcut to do the toggling.

I modified his script slightly as I did not want the TrayTip popping up whenever I switched between modes. I also wanted my toggle to be the CTRL-SHIFT-U keys instead of CTRL-ALT-U.

The following zip file contains the modification:

You can find the original here on Dave's post.

Thanks for taking the time to improve the script and let me know Dave!!

Develop With Passion!!

Comments [1] | | # 
 Tuesday, May 27, 2008
Tuesday, May 27, 2008 2:46:21 PM (Mountain Standard Time, UTC-07:00) ( Training )

A venue change has occurred as the original hotel could not provide us with the room for the whole day on the Thursday!!

The course in Vancouver next month is now going to be held at the Empire Landmark Hotel. I am pretty excited, as the space we are being given is pretty spectacular.

If you are planning on attending, sign up here. If you happen to book a room in the hotel itself (recommended) make sure that you mention that you are attending Nothin But .Net and you will receive a $30 discount on the room.

I apologize for any inconvenience.

Develop With Passion!!

Comments [0] | | # 
Tuesday, May 27, 2008 1:14:35 PM (Mountain Standard Time, UTC-07:00) ( Tools )

Well, it has been a good run and the BDD Macro has served its purpose to help me get into the swing with going down the BDD path, but now I find myself wanting a little bit more!!

After a quick email from Dave I thought I would take a quick look at AutoHotKey to see how it could help me accomplish my end result much simpler. Here are the 2 autohotkey scripts that I created to accomplish the end result:

replace_spaces_with_underscores.ahk:

#SingleInstance force
Space::_

spaces_back_to_spaces.ahk:

#SingleInstance force
Space::Space

 

In my main autohotkey script (which is located in My Documents) I added the following lines of code:

^!u::Run C:\utils\autohotkey\jpscripts\replace_spaces_with_underscores.ahk
^+u::Run C:\utils\autohotkey\jpscripts\spaces_back_to_spaces.ahk

The first line tells autohotkey that whenever the CTRL-ALT-U combination is pressed that it should run the replace_spaces_with_underscores.ahk to enable underscores being placed whenever I hit the space key.

The second line tells autohotkey that whenever the CTRL-SHIFT-U combination is pressed that it should run the spaces_back_to_spaces.ahk to switch the space key back to its normal behavior.

Autohotkey starts up at Windows start up, so I can use these commands no matter which application I am in. I have attached the script files. I also recorded a quick screencast, but I cannot currently upload it to my FTP server (issues). I have a feeling that me and AutoHotKey are going to become fast friends!!

Develop With Passion!!

Comments [2] | | # 
 Monday, May 26, 2008
Monday, May 26, 2008 10:19:28 PM (Mountain Standard Time, UTC-07:00) ( General )

Hot on the heels of the Toronto course completion, one of the attendees (Michael Sevestre) just emailed me with a small update that fixes the issue on trying to reapply the macro to the name of the context when it is now inheriting from a base context class.

Thanks Michael, it is greatly appreciated!!

The update is below:

Imports System

Imports System.Windows.Forms
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module CodeEditor

    Public Sub ReplaceSpacesInTestNameWithUnderscores()
        If DTE.ActiveDocument Is Nothing Then Return
        Dim wrCS As Boolean = DTE.Properties("TextEditor", "CSharp").Item("WordWrap").Value

        Try
            DTE.Properties("TextEditor", "CSharp").Item("WordWrap").Value = False
            Dim selection As TextSelection = CType(DTE.ActiveDocument.Selection(), EnvDTE.TextSelection)
            Dim index As Integer

            selection.SelectLine()
            If selection.Text = "" Then Return

            Dim methodIndex As Integer = selection.Text.IndexOf("public void ")
            Dim classIndex As Integer = selection.Text.IndexOf("public class ")
            Dim implementIndex As Integer = selection.Text.IndexOf(":")

            If (methodIndex < 0 AndAlso classIndex < 0) Then Return

            index = CType(IIf(methodIndex >= 0, methodIndex, classIndex), Integer)

            Dim prefix As String = CType(IIf(methodIndex >= 0, "public void ", "public class "), String)
            Dim whiteSpace As String = selection.Text.Substring(0, index)
            prefix = whiteSpace + prefix

            Dim description As String = selection.Text.Replace(prefix, String.Empty)

            'Find the ":" at the end of the line if defines
            Dim suffix As String = String.Empty
            If (implementIndex >= 0) Then
                suffix = selection.Text.Substring(implementIndex).Trim()
                description = description.Replace(suffix, String.Empty)
                suffix = String.Format(" {0}", suffix)
            End If

            description = description.Trim
            Dim text As String = prefix + description.Replace(" ", "_").Replace("'", "_") + suffix + vbCrLf
            selection.Delete()
            selection.Insert(text)
            selection.LineUp()
            selection.LineUp()
            selection.SelectLine()
            If selection.Text.Trim = "{" Or selection.Text.Trim = "}" Or selection.Text.Trim = "" Then
                If selection.Text.Trim = "{" Or selection.Text.Trim = "}" Then
                    selection.Insert(selection.Text.Replace(vbCrLf, "") + vbCrLf)
                ElseIf selection.Text.Trim = "" Then
                    selection.Delete()
                End If
            End If         
            selection.EndOfLine()
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            DTE.Properties("TextEditor", "CSharp").Item("WordWrap").Value = wrCS
        End Try
    End Sub
End Module

Comments [2] | | # 
Monday, May 26, 2008 11:57:23 AM (Mountain Standard Time, UTC-07:00) ( General )

Just flew in yesterday afternoon from an amazing week and a half in Toronto. This was one of the first trips in a while that my wife and I went without the kids! They had a great time hanging out with both sets of Grandparents.

We flew into Toronto last Wednesday (the 14th) and we spent most of the day just walking around Toronto trying to get a feel for the place. This was my first time back to Toronto in 15 years and my wifes first time there ever!!

On Thursday I jumped into DevTeach to give 2 presentations :

  • Applied Domain Driven Design
  • Generics - They're not just about collections

The feedback from the sessions was awesome, and I got to spend some time catching up with people I have not talked to in a while.

On Friday, I spent the day pair presenting with Scott for the post-con workshop on Behavior Driven Development. I feel like the workshop went well, lots of lessons learned, but each course only gets better!! That same evening my wife and I went to "Medieval Times"!!! I purchased the Royalty package, so we got to sit right in the front row to witness all the action up close. In reality, the seating is laid out so well that you will be able to get a good viewpoint from any part of the arena. It was an absolute blast. The food was amazing, and the presentation itself was fabulous. We have made it a point to now try and see Medieval Times in each location where it is actually delivered (which is only a small set of locations)!!!

Saturday we spent the day walking and shopping. Checking out markets was fun, and eating in restaurants without the kids running around our feet was quite a surreal experience!!

On Sunday the 18th we left our hotel room at 8:00AM in the morning to go and spend the day taking a guided tour of Niagara Falls. This was definitely an unforgettable experience. Taking part in the Maid of the Mist tour is a memory that I am sure will be etched into both of our minds forever. We also got to spend a little bit of time checking out Clifton Hills, which had lots of fun amusement rides and shops!! The day finished off with a guided wine tasting at a local vineyard.

The week of the 19th was an extremely busy week, as I was delivering another Nothin But .Net Course at the Marriott Bloor Yorkville!! It was myself and 11 other attendees, and the week was an absolute blast. The amount of information that we managed to cover was staggering and I am sure that everyone involved had a great time!! One of the highlights of the week was when my wife came in and presented the class with T - Shirts that said the following on the front:

"I survived Jean-Paul Boodhoo's .Net Bootcamp!!!"

Going forward, we are going to absolutely have to make sure that everyone gets a T-Shirt!!

We are now back in Calgary, we have been reunited with the kids, and I have a couple of weeks of heads down crazy codin to do before the next course in Vancouver.

God Bless and,

Develop With Passion!!

Comments [1] | | # 
 Friday, May 23, 2008
Friday, May 23, 2008 7:12:39 AM (Mountain Standard Time, UTC-07:00) ( Tools )

I might be late of the presses making the announcement, but I am sure that I am one of the few who has been updating their build of ReSharper almost daily for the last couple of moths (except when it is a not recommended build). I just can't understate the awesomeness of this amazing tool!! I plan to do a ReSharper Jedi coding session with music and all in the next couple of weeks where I am going to go full tilt with Viemu and ReSharper 4.0. I think that the best way to sell people on the value of code productivity tools is to show them in action.

If you feel like living on the edge, go and download the latest nightly build from here.

Develop With Passion

Comments [0] | | # 
 Monday, May 19, 2008
Monday, May 19, 2008 2:13:36 PM (Mountain Standard Time, UTC-07:00) ( Programming )

I noticed a small error in the BDD macro that I have just fixed. The text of the macro is below:

Imports System

Imports System.Windows.Forms
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module CodeEditor

    Public Sub ReplaceSpacesInTestNameWithUnderscores()
        If DTE.ActiveDocument Is Nothing Then Return
        Dim wrCS As Boolean = DTE.Properties("TextEditor", "CSharp").Item("WordWrap").Value

        Try
            DTE.Properties("TextEditor", "CSharp").Item("WordWrap").Value = False
            Dim selection As TextSelection = CType(DTE.ActiveDocument.Selection(), EnvDTE.TextSelection)
            Dim index As Integer

            selection.SelectLine()
            If selection.Text = "" Then Return

            Dim methodIndex As Integer = selection.Text.IndexOf("public void ")
            Dim classIndex As Integer = selection.Text.IndexOf("public class ")

            If (methodIndex < 0 AndAlso classIndex < 0) Then Return

            index = CType(IIf(methodIndex >= 0, methodIndex, classIndex), Integer)

            Dim prefix As String = CType(IIf(methodIndex >= 0, "public void ", "public class "), String)
            Dim whiteSpace As String = selection.Text.Substring(0, index)
            prefix = whiteSpace + prefix
            Dim description As String = selection.Text.Replace(prefix, String.Empty).Trim
            Dim text As String = prefix + description.Replace(" ", "_").Replace("'", "_") + vbCrLf
            selection.Delete()
            selection.Insert(text)
            selection.LineUp()
            selection.LineUp()
            selection.SelectLine()
            If selection.Text.Trim = "{" Or selection.Text.Trim = "}" Or selection.Text.Trim = "" Then
                If selection.Text.Trim = "{" Or selection.Text.Trim = "}" Then
                    selection.Insert(selection.Text.Replace(vbCrLf, "") + vbCrLf)
                ElseIf selection.Text.Trim = "" Then
                    selection.Delete()
                End If
            End If
            selection.LineDown()
            selection.LineDown()
            selection.EndOfLine()
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            DTE.Properties("TextEditor", "CSharp").Item("WordWrap").Value = wrCS
        End Try
    End Sub
End Module

Comments [1] | | # 
 Monday, May 12, 2008
Monday, May 12, 2008 3:20:09 PM (Mountain Standard Time, UTC-07:00) ( Programming )

I just completed a reorganizing of the solution that I am currently working on. I now have only 2 projects in the solution. I use to have 3 project:

  • {ApplicationName} - This contained the project for the application itself, all of the logical layers lived in this project.
  • {ApplicationName}.Test - The unit tests for the Application (integration and unit)
  • {ApplicationName.Build - All of the artifacts related to managing the build process

After the reorg that just took place over the last 1 hour it is now:

  • {ApplicationName} - Same as before, except now each spec/specs live beside the code it is testing.
  • {ApplicationName}.Build - Same as before

Thanks to the power of ReSharper and an existing NAnt build file that I was already using to manage the project build/compilation/test ... It took me 40 minutes to do the file shuffling. ReSharper helped out with the namespace changes. 3 lines of xml added to the build script (no other changes required) and I am back in business!!

I love ReSharper!! And yes, I am running the latest nightly build (797) and it has been running amazingly. I currently have Solution Wide Error Analysis turned off, as it seems to slow things down a little.

Comments [7] | | # 
 Sunday, May 11, 2008
Sunday, May 11, 2008 4:18:21 AM (Mountain Standard Time, UTC-07:00) ( C# )

For the longest time (the last 4 months!!) I have been using the following style of code to determine whether exceptions are thrown in my codebases:

typeof (InterfaceResolutionException).ShouldBeThrownBy(() => DependencyRegistry.GetMeAn<IDbConnection>());

As you can see, all that I am doing here is leveraging an extension method that hangs of the type class:

public static void ShouldBeThrownBy(this Type exceptionType,Action workToDo) { GetExceptionFromPerforming(workToDo).ShouldBeAnInstanceOf(exceptionType); }

This extension method lives in a library of extension methods that I use when doing Behavior Driven Development and trying to leverage natural language as close as possible vs the traditional Assert this/that.

I just switched it up a bit to change it to make it completely foolproof, as with the original extension method you could have easily done this:

typeof (SqlConnection).ShouldBeThrownBy(() => DependencyRegistry.GetMeAn<IDbConnection>());

This code would compile and run, but SqlConnection is not an exception type. What I want to be able to do, to address this issue is flip things around like this: 

(() => DependencyRegistry.GetMeAn<IDbConnection>()).ShouldThrowA<InterfaceResolutionException>();

Notice how I am trying to use 2 different concepts here:

  • Extension methods having off of a lambda expression
  • Generics to ensure that the type provided to the ShouldThrowA method is an derivative of Exception

The only real problem with this is that you can't have an extension method that hangs off a lambda. What I can do is the following to get started:

public static void ShouldThrowA<ExceptionType>(this Action workToDo) where ExceptionType : Exception { GetExceptionFromPerforming(workToDo).ShouldBeAnInstanceOf<ExceptionType>(); } public static Exception GetExceptionFromPerforming(Action work) { try { work(); } catch(Exception e) { return e; } return null; }

The first thing that I did is to create an extension method that belongs to any Action delegate instance. Notice the use of the generic constraint to ensure that the generic type parameter provided to the method is an actual derivative of Exception, which ensures that using this method is only applicable to exception throwing behaviors for a specific exception type. The second method GetExceptionFromPerforming (you will notice that I commonly use a style of naming that makes the method name coupled with its parameters the full name of the method, read the line as GetExceptionFromPerforming(work) vs GetExceptionFromPerformingWork(work), just a little bit of redundancy I don't care for) returns the exception caught while trying to execute the Action.

The ShouldBeAnInstanceOf method is another extension method that gets associated with any object, it just makes use of an existing assertion in the MbUnit library.

All of the building blocks are in place there is only one problem. I can't do this:

(() => DependencyRegistry.GetMeAn<IDbConnection>()) .ShouldThrowA<InterfaceResolutionException>();

So with just the following new class added to the my BDD Extensions Class:

 

public static class The { public static Action Action(Action workToDo) { return workToDo; } }

Looks a little weird, to have a method that looks like all it is doing is returning what it was called with, but in this case it is actually allowing us to allow assignment of the lambda to a known type which ultimately allows us to have extension methods that are bound to that known type (in this case the Action delegate). With all of these places in place this is how I now do assertions for exceptions thrown in a piece of SUT code:

The.Action(() => DependencyRegistry.GetMeAn<IDbConnection>())
                    .ShouldThrowA<InterfaceResolutionException>(); 

 

In this code the SUT is the DependencyRegistry which is actually a Static Gateway to container functionality.

Develop With Passion!!

Comments [3] | | # 
Sunday, May 11, 2008 2:36:37 AM (Mountain Standard Time, UTC-07:00) ( Agile )

First and foremost I have to stress my great amount of respect for Carl and what he does for the development community.

In the current DNR episode in which Carl and Richard interview Phil Haack there is a portion in the show where Carl makes some statements about Test Driven Development.

The two statements that  he makes are:

"Test first is just one extreme of test driven development"

"according to JP Boodhoo the whole test driven development ranges from wrapping NUnit tests around existing functions on one end of the spectrum and then test first on the other end of the spectrum but most people fall somewhere in between"

These are not my thoughts/practices with regards to Test Driven Development. I feel that test driven development is first and foremost a design activity that is used to flesh out the design of a component by creating a test that first describes the API it is going to expose and how you are going to consume it's functionality. The test will help shape and mold the System Under Test until you have been able to encapsulate enough functionality to satisfy whatever tasks you happen to be working on.

IMHO TDD as an activity requires the creation of the test code before you write any production code for the component itself. This is the way I personally develop as well as the way I teach and mentor people with respect to practicing TDD.

When you go into an existing code base and start wrapping tests around existing production code that is already there, that is Unit Testing, not TDD.

Develop With Passion!!

Comments [4] | | # 
 Friday, May 09, 2008
Friday, May 09, 2008 7:13:10 PM (Mountain Standard Time, UTC-07:00) ( General )

Well, I guess I'll know for next time how many days it takes for me to get 79 responses for a freebie giveaway!! The 3 winners just got sent their amazon gift credits. And yes, the 79th email just came in a couple of hours ago!!

Tell your friends, tell your coworkers. This is far from the last freebie of the quarter!!

Develop with Passion!!

Comments [0] | | # 
 Thursday, May 08, 2008
Thursday, May 08, 2008 1:19:20 PM (Mountain Standard Time, UTC-07:00) ( Training )

With the window for registration for the Toronto course soon coming to a close, it is time to start registration for another iteration of Nothin But .Net to be held in Vancouver. You can register for the course here. Like all of the recent public courses, this course will also be held in the conference room of a hotel, so travelers will be able to stay in the hotel the course is being hosted in. This statement is also known as : prepare for long days!!! We are blessed to be able to have the beautiful Empire Landmark Hotel at our disposal, this will give us some great lunch and dinner options (remember, you don't have to pay for any of the meals) as well as some potentially nice walks near the ocean!!

I am anticipating that this class will fill up fast, so if you are ready to take your skills to the next level, register today!!

Overview

Nothin But .Net is a five day (intense) boot camp style course that will focus on applying .Net development best practices in the context of developing a working N-Tiered application. Registrants will learn about how to practically apply.Net as they apply it to the task of building a complete application from the UI layer all the way down to the mapping layer.

 

WARNING!!!!

If you are expecting to come to this course to learn about how to have VS.Net automatically generate an “application” for you, then this course is NOT for you.

This course is all about taking control of the .Net framework and having it work the way you want. This course will place a heavy emphasis on getting back to the basics and making .Net do things the way you want it to, in a predictable and testable way.

During the course of the week, there will be absolutely no code that gets compiled from within Visual Studio. Studio itself will be relegated to a glorified code editor. I will teach you development techniques and tools that will dramatically increase your day to day productivity as a software developer.

This course will focus on a code centric view of application development vs. the typical databinding/designer magic covered by many typical .Net courses. You will walk away with a deep understanding of fundamental aspects of .Net and how these pieces can be used to develop and deliver enterprise scale applications.

Core Concepts Overview

*        Expand the capabilities of developing with VS.Net - Enter ReSharper (a productivity add-in for Visual Studio .Net)

*        There’s more to development than code generators

*        Automated Builds       

*        Generics ( they’re not just for collections )

*        Object Relational Mapping in .Net

*        Creating layered architectures

*        Driving out functionality and design through testing

*        Taking Control Of Databinding

*        Test Driven Development & Mock Objects

*        Core Design Patterns Applied

 

Detailed Topic Coverage Breakdown

·          Language Enhancements