About Me

Training

Nothin But .Net Developer Bootcamp

Navigation

Search

Categories

On this page

Course Registration Issues
Getting syntax highlighting for your powershell scripts (take 2)
Nothin’ but .NET – Reaching out
Screen capture in OSX
I’m not on Jetbrains payroll
Creating an Ubuntu 8.10 Desktop VM on VMWare Fusion
ReSharper 4.5 – Red Bull for VS
Digital Productivity Strategies For Developers
What’s up with my VS2008 install?
Focus on fun and step into freedom in your career!!
DevelopWithPassion@GitHub
Wow, the difference a single line can make!!
ReSharper Helper – AutoHotkey Script
Credit where credit is due
developwithpassion.bdd
Visual Studio Color Settings
Code is headed your way
Triggering events on UI components (WinForms)

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: 519
This Year: 28
This Month: 0
This Week: 0
Comments: 1593

 Thursday, March 26, 2009
Thursday, March 26, 2009 7:20:00 PM (Mountain Standard Time, UTC-07:00) ( Training )

There have been several groups of people who have got in contact with me to let me know about problems they have been having with the course registration process. The limitation right now is a PayPal issue. They are unable to allow transactions larger than $4000 USD.

This is not a problem for people who are registering sole attendees. It is, however, a problem if you are trying to register more than one person at a time.

For the interim, if you need to register a group of people I would ask that you kindly register each attendee one at a time. This situation will be remedied in about a month when we will be switching to a custom solution that will not have these limitations. Until that rolls out I kindly ask for your patience and understanding in the matter.

I assure you that steps are being taken to rectify the situation as quickly as possible!!

Develop With Passion!!

Comments [1] | | # 
 Tuesday, March 24, 2009
Tuesday, March 24, 2009 2:00:00 PM (Mountain Standard Time, UTC-07:00) ( Tools )

Since I just had to recently get my machine scaffolded again, I had a chance to revisit this item. I think this time I got it figured out a little better!!

For reference this is what my vim folder looks like:

image

Download the following files (I place them in the appropriate folders in my vimfiles folder:

http://www.vim.org/scripts/script.php?script_id=1327 (Syntax File)

http://www.vim.org/scripts/script.php?script_id=1815 (Indent File)

http://www.vim.org/scripts/script.php?script_id=1816 (File Type Plugin)

Once I had copied those files into the appropriate folders:

vimfiles\syntax

vimfiles\indent

vimfiles\ftplugin

I edited my _vimrc file and have the following section (just before the syntax on command):

image

With that done I can open up a powershell file and get syntax highlighting.

Unlike in the last post, this solution will also allow me to upgrade my version of Vim without issues as I am now placing custom plugins in my vimfiles folder (under version control, so I can quickly rebuild a machine if needed!!), as well as the fact that I am making use of my _vimrc file to enable the custom plugin.

Develop With Passion!!

Comments [0] | | # 
Tuesday, March 24, 2009 7:40:00 AM (Mountain Standard Time, UTC-07:00) ( C Sharp | Training )

There are some big, big changes coming this year that will revolve around how Nothin' but .Net promotes the cause of education. Registration for courses started a couple of weeks ago and I am excited about the potential that this year brings for people who are going to be registering.

After a couple of tweets in the twittersphere, and a great recommendation by Scott; I realized that there were a couple of things that I could do this year to promote the cause of education and make the training a little more accessible. This post outlines the high level plans that are going to be implemented as soon as possible.

In no particular order the items are:

NBDN Scholarship Program
There are lots of people out there who are desperately wanting to get involved with some form of high quality training. Unfortunately, there are also a lot of people who just do not have the resources/support to undertake the financial weight of the course. To that end, this year for each class there is going to be a scholarship issued to one person who will have their complete course tuition wavered. This does not include airfare and accommodations, just the ticket price for a seat in the class. One of the things we are deciding right now is how to go about deciding the format for how this process should work. How do we pick from a potential pool of people who may want to attend the course. Based on the contest I ran last year, it may not be that difficult as in spite of all of the freebies that were being given out, there were very few actual "submissions". If you have any suggestions on how I should structure the "submission" process it would be greatly appreciated. Right now I am leaning in the direction of having people submit stories that describe why they should be awarded the scholarship.

NBDN Course Primer
In the cities where I can coordinate this (and get the timing right), there is going to be a free 1 day primer course that will be open to the public so that they can come and discuss, code, and get a feel for what the scope of the course will entail. My plan for the primer course is to spend the day working through concepts that I feel are prerequisite knowledge, make developers more productive in general, as well as to dive into some code, patterns, and concepts that people should be familiar with (especially if they want to take the course at a later time). Like the course, there will be limited seating (16-20 max), and people will be expected to come with open minds ready to challenge, learn, and have fun. One bonus (in the cities where there is participation) will be the opportunity to work and share discussions with past students (from the local area) who can speak openly and honestly about their experience with the course. In the primer course day people will get exposure to the following :

  • Build automation with rake/powershell
  • Context/Specification style testing
  • Back to advanced basics with core .Net
  • Fundamental Design Principles

Although it is termed as a primer, the goal of the day is to have people leave with their head stuffed full of new ideas and approaches they may not already be familiar with. The reason for the size of the class is to enable as much rich communication as possible, which is very difficult to do in large class sizes. I expect these primers to generate a lot of questions!!

DNRTv
After a great discussion with Carl, we have decided to set some time aside in May to record 2 full days worth of training material. Again, the goal with these videos is to serve as primers for people to get exposed to many concepts that can be instrumental in making them more productive developers. These videos will be extremely code intensive, and should leave people with a greater awareness of tools and techniques they may not already be familiar with. The scope and material that will be covered in these two days is yet to be determined, though my hope is that these videos will give people a great deep introduction to a host of topics.

As you can see, there are lots of plans that are in store this year and I am excited about what the Lord has in store for myself and all of the people I hope to interact with!!

Develop With Passion!!

Comments [7] | | # 
 Monday, March 23, 2009
Monday, March 23, 2009 7:20:00 PM (Mountain Standard Time, UTC-07:00) ( Tools )

Great article outlining the built in screen capture mechanisms on the mac : http://graphicssoft.about.com/od/screencapturemac/ht/macscreenshot.htm

Overview (copying to clipboard):

  • Entire desktop: Command–CTRL-SHIFT–3
  • Windows: Command-CTRL-SHIFT-4, press space, select window
  • Selection:Command-CTRL-SHIFT-4, select area

 

Develop With Passion!!

Comments [2] | | # 
Monday, March 23, 2009 2:11:00 PM (Mountain Standard Time, UTC-07:00) ( Tools )

The last post resulted in a great comment that I thought deserved some blog time:

“Given that you sometimes give out ReSharper licenses when you present, and often give it such glowing attention, I wonder if you have ever addressed the question of your relationship, if any, with JetBrains.
I have always assumed that you just value R# so much that you magnanimously want everyone to know about it and be productive to their greatest potential (there's that "passion"), but to the uninitiated it can certainly seem that you have some sort of a sponsorship/endorsement deal with JetBrains. I have no issues with it, either way--I'm hooked on R#.
In the interest of transparency, though, perhaps you could address this in a separate post and just prepend a link to it in posts like this one, so everyone is clear about the extent to which your accolades for R# are or are not a paid advertisement.”

I value R# a lot and want to expose as many people as I can to it, as I believe it can truly become a killer tool in a C# developers arsenal. Of course, this year is also going to be the year that I will be raving about Vim, ViEmu etc, and the same holds true in the case of those tools. I will be talking, and blogging about them as they are tools that help me achieve a great amount of coding productivity. I am a big fan of honing a sharp dev toolkit, pruning the fat when necessary, and always being on the lookout for better way to do things, be that leveraging new development tools or otherwise.

JetBrains does provide me with a free R# license for each public presentation that I do, but this is also the case for most people who take the time to get in contact with them and ask (of course, you need to be using the product!!). They also are very helpful in providing a discount to me when purchasing "full" licenses for the course (because of the volume of licenses). In both cases, they were very open and gracious to my requests for both. There is no agreement that states that I need to name drop the tool every "x" times in order to maintain either of these collaborations.

So the short answer is that I am just a developer who loves a coding productivity tool that I am happy to share with anyone who wants to listen/watch!!

I just wanted to make sure that people who feel that I am marketing the product for my own personal monetary gain can see that I am not; that I am just a coder, who loves to write code, and loves to use the best tools that allow me to produce code with the least amount of friction possible!!

Develop With Passion!!

Comments [5] | | # 
Monday, March 23, 2009 11:59:00 AM (Mountain Standard Time, UTC-07:00) ( Tools )

This guide is mostly for me to remind myself how I got my current ubuntu 8.10 desktop edition installed.

I want to quickly make it very clear that I am “not” an experienced linux user, so this is my account of how I got my current install going. Any suggestions on how to repeat the process in a much more streamlined way will be greatly appreciated!! And now that I have been using it for a couple of months (sparingly), I know how to repeat the process for a server only installation, I just have not had the need to switch my vm as of yet.

Here it is:

  • Download Ubuntu desktop (the cd image)
  • VMware Fusion – File –New
  • Click continue without disk

 

Picture 1

  • Choose the “use operating system installation disk image file” option and choose the disc image you downloaded, click continue.

Picture 2

  • Use the defaults on the following screen

Picture 3

  • On the following screen you can choose whether you want the VM to be able to access your home folder (I chose not to). I also provided the Easy Install information

Picture 4

  • On the last screen you will have the option to customize settings for the VM, when you click the “Customize Settings” button you will be prompted for a save location for the VM file.

Picture 5

  • Then the VM cutomization dialog will pop up:

Picture 6

 

  • The only customization I made was to change the RAM from 512MB to 256MB (after I have finished installing everything, I drop it to 128MB)
  • Start up the VM (you should see the Ubuntu loading dialog & progress bar)
  • Once the desktop is loaded it should start the install process automatically, it will restart and login automatically if you chose the easy install option (above)

Picture 7

 

Post Install Steps (setting up tools)

In the following commands, don’t type out the ESCAPE/ENTER keys!!

General Tools

    • Open  a terminal window (Applications –> Accessories –> Terminal)
    • sudo apt-get update<ENTER>
    • sudo apt-get install vim<ENTER>
    • sudo apt-get install firefox<ENTER>

Setting up subersion

    • Open  a terminal window
    • sudo apt-get install subversion<ENTER>
    • sudo vim<ENTER>
    • isvnserve –d –r /repositories<ESCAPE>
    • :wq /etc/init.d/subversion<ENTER>
    • You should now be back at the terminal
    • The previous vim jazz created a file that will be used on startup to get the subversion daemon started, before that can happen we have to make the file executable
    • sudo update-rc.d subversion defaults<ENTER> (prepares the subversion file to be run at startup)
    • sudo chmod +=rwx /etc/init.d/subversion<ENTER> (this change the file modifiers to read/write/executable, needs to be executable to fire up at startup)
    • sudo mkdir /repositories<ENTER> (creating the folder that will be watched by subversion)
    • At this point, you now have a basic subversion installation that can be administered using regular subversion means (I’m assuming familiarity with subversion command line tools). To create a new repository, you can drop to the terminal and create a new repo as follows:
      • sudo svnadmin create /repositories/[new_repository_name]

Develop With Passion!!

Comments [2] | | # 
 Friday, March 20, 2009
Friday, March 20, 2009 6:56:00 PM (Mountain Standard Time, UTC-07:00) ( Tools )

If you happen to be one of the many developers who are still coding up a storm in a Vanilla visual studio installation. This post is for you.

ReSharper is for many developers, myself included, a killer app and absolute necessity for staying productive while coding inside of visual studio. It is a coding productivity addin that adds a whole host of features that, if you are working in a plain VS install, you may not even realize how much you are missing.

A small bullet list of key features you may like are:

  • Smart Code Navigation
  • Refactoring
  • Solution Wide Error Analysis

Those three bullet points actually expand out into a ton of features that would take way too much time to talk about!!

I have been working with ReSharper ever since it's first EAP builds were available a couple of years ago. Let me tell you that it has become a deal breaker for me with potential clients if I am requested to work on a machine without this tool. It is truly hard to express in mere words how much more productive you can become as a code writer when making use of this tool.

I won't bore you with too many details as the best advice I can give is to go an download a copy of Resharper and give it a test run for a couple of weeks. You really need to commit to a 2 week stint with significant coding time, if you really want to see what it could do for you. Even then, you really need to see it in action being utilized by someone who is extremely proficient in it, before you can really appreciate what it might be able to help you with.

Another thing that I need to stress is the responsiveness of the Jetbrains team in dealing with errors you may run into. The ability for them to interact and deal fast to issues that are raised by the community is truly amazing. I have had several issues in the last week that were resolved and integrated into latter builds very fast.

The current version is 4.1, though I recommend installing the 4.5 beta and giving it a whirl. Download Scott's awesome build updater and stay in sync without having to manually check!!

Develop With Passion!!

Comments [7] | | # 
 Wednesday, March 18, 2009
Wednesday, March 18, 2009 10:40:00 PM (Mountain Standard Time, UTC-07:00) ( General | Tools )

Back in December I recorded a podcast with Craig Shoemaker of the Polymorphic Podcast. We had a discussion about tools and techniques that I used to stay productive while on the road. Even if you don't find yourself doing a lot of travelling, lots of the tricks/tools we discussed could be things that you may find useful.

Develop With Passion!!

Comments [1] | | # 
Wednesday, March 18, 2009 4:40:00 PM (Mountain Standard Time, UTC-07:00) ( Tools )

This is a request for help, as I don’t want to have to reinstall studio unless I really have to. I’m not sure if I accidentally changed a font setting for dialogs in studio, but all of my dialogs look like this now:

image

My ide font is fine, and everything else seems to be ok, but any VS dialog that I bring up is having the text rendered the same way. I done a repair of the installation, but it’s still there. I wondering if I accidentally changed a font setting in VS that I was not aware of.

Any ideas would be greatly appreciated!!

Comments [7] | | # 
 Monday, March 16, 2009
Monday, March 16, 2009 4:30:00 PM (Mountain Standard Time, UTC-07:00) ( Inspiration )

Over the last year and a half I have had the opportunity to both work and teach with people from all across the world. One of the things that I have realized after talking with a lot of developers is that too many of us are just "surviving".

When I say surviving I mean that too many developers are waking up in the morning, unmotivated and unhappy with what they are doing and this can often permeate into other aspects of their life. One of my personal challenges is to wake people up to the potential that is buried inside of them.

One recurring theme has surfaced. Lots of developers are unhappy because they feel they are losing a comparison game that they are unfortunately playing. They are swamped with all of the information coming at them by people on "blogs, twitter, facebook, screencasts, podcasts". They no sooner learn a new topic and then realize that one of the people they are following has already moved onto 15 new topics that they are now mastering. This can quickly become a very self defeating thing. Instead of savoring the journey, which is learning for them self, progressing at a pace that is comfortable to them, and one upping their personal abilities day after day; they become demoralized at the inability to "keep up".

If you find that you may be one of those people. I am going to give you some advice that I think could have a dramatic result if actually applied. "Start having fun again". Why did you get into programming in the first place? For me, it was the challenge and the ability to flex my creative muscles!! I love being able to take an idea and see it manifest in code, and finally into something that I can see working before my own eyes.

One of the things I often say to people is "I remember when I was coding several years ago, I was hacking stuff out, I was not really doing unit testing, but I was having a blast." The focus on fun was what naturally drew me to want to improve. I started disliking how I had to manually run through my app when I made a change, this led me to look into unit testing. Why did I do this, because it was not "fun" to have to waste my time on something the computer could do for me much faster. It was not fun to want to make a change and have a single change cause ripple effects through the system I was working on. This led me to learn about SRP and other fundamental design principles. For the first 6 years of my career I was not a blog reader, but that did not prevent me from naturally improving my skill set.

Why was I improving? I wanted to keep the "fun" in the work that I was doing. Continual micro improvements made over the course of a 6 year period allowed a development transformation that would not have been possible if I was continually comparing myself to somebody else, as I would have been too focused on their efforts and not my own. I wanted to improve to do my job better and to be able to continue enjoying what I was doing. Instead of falling in to repetition, that can ultimately lead to boredom and dissatisfaction.

This has cause me to realize and remember a fundamental point:

"If you invest your time and effort trying to "catch" up with someone you want to be like, it is very possible that when you "think" you are at their level, that they are in a completely different place"

I see so much wasted time and energy being poured into this completely fruitless chase. If you stay too focused on a destination, you can often miss the blessings of the journey. Don't waste another second of your time missing the journey. Take ownership of your journey again, and make it your own, custom, experience. I can read about how amazing the rocky mountains are, but until I see them for myself, I can’t truly appreciate how beautiful they are.

There is an amazing verse in the Bible that has always kept me going throughout my career and life, and I feel it has provided me with a healthy outlook with how I carry out my career:

"Whatever you do, work at it with all your heart, as working for the Lord, not for men, since you know that you will receive an inheritance from the Lord as a reward. It is the Lord Christ you are serving." - Colossians 3:23-24 (NIV).

It is my prayer today for those of you that are in self imposed "comparison prisons" that you will be set free from those chains, and start walking in the amazing freedom that has been granted to you. How blessed we are to be in a job that we chose to be in. We can wake up in the morning and get paid for doing what we love doing. Make it your personal goal this year to learn one new thing a day, not because you think you should, but because you want to improve your craft. Do it for yourself, for the benefit of your employer and your family. Stop worrying about keeping up with the pack and start focusing on having fun again. I have much more to say about this topic, but for now, I think that is enough!!

Develop With Passion!!

Comments [14] | | # 
Monday, March 16, 2009 1:00:00 PM (Mountain Standard Time, UTC-07:00) ( General )

With my comfort level with Git rounding the “not so uncomfortable” I decided to throw myself in heads first and move the code that I currently have hosted on assembla over to GitHub. All of the code samples that I publish now are going to be under the “Develop With Passion” banner.

GitHub is an easy choice as it makes the collaboration story much richer for people who potentially want to contribute changes to any of the source code that will live up there (as soon as I’m finished this startup at the end of April, my first task list item is to get much more code up there!!).

Currently the only project that is hosted up there is : developwithpassion.bdd

If you are unfamiliar with Git and its associated set of tools I am going to point you in the direction of an awesome post that Aaron put together which should be instrumental in getting you up and running. If you want to quickly get up to speed on git (on windows) I would recommend the following resources (Aaron mentions most of these in his post also):

Develop With Passion!!

Comments [3] | | # 
Monday, March 16, 2009 7:05:00 AM (Mountain Standard Time, UTC-07:00) ( C Sharp )

I have not changed my build script for my current project for a little while. As the project started to get bigger I started to notice a significant slowdown in building from my build script. I stopped to take a look at my script this morning and smacked my head when I saw what was going on. It read like the following:

$result = MSBuild.exe "$base_dir\solution.sln" /t:Rebuild /p:Configuration=Debug

A quick change to the following and it was all good:

$result = MSBuild.exe "$base_dir\solution.sln" /t:Clean /t:Build /p:Configuration=Debug

Micro optimization is where its at!!

Develop With Passion!!

Comments [4] | | # 
 Thursday, March 12, 2009
Thursday, March 12, 2009 6:08:00 PM (Mountain Standard Time, UTC-07:00) ( Tools )

In my quest to keep my fingers as close to home row as possible, I am publishing the script I used to allow me to hit most of the ReSharper shortcuts I use by staying on home row. To run this you will have to:

  • Run AutoHotkey
  • Not worry about having different Resharper keyboard shortcuts than most!! (you can still use the original ones if you want!!)

Here is the script:

;==========================
;Initialise
;==========================
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode 2

;==========================
;Process Move Down A Method
;==========================
$!J::
    Send, !{Down}
return

;==========================
;Process Move Up A Method
;==========================
$!K::
    Send, !{Up}
return

;==========================
;Process Move Method Up
;==========================
$^+!K::
    Send, ^+!{Up}
return

;==========================
;Process Move Method Down
;==========================
$^+!J::
    Send, ^+!{Down}
return

;==========================
;Process Go to next usage
;==========================
$+!J::
    Send, ^!{Down}
return

;==========================
;Process Go to previous usage
;==========================
$+!k::
    Send, ^!{Up}
return

;==========================
;Process Generate Code
;==========================
$!I::
    Send, !{Insert}
return
;==========================
;Highlight Current Usages
;==========================
$!8::
    Send, ^+{F7}
return
;==========================
;Find Usages
;==========================
$!9::
    Send, !{F7}
return
;==========================
;Next Error In Solution
;==========================
$!0::
    Send, !{F12}
return

Comments [1] | | # 
Thursday, March 12, 2009 3:00:00 PM (Mountain Standard Time, UTC-07:00) ( Tools )

A couple of people have been contacting telling me about how much they are enjoying using the developwithpassion.bdd library. I just wanted to point out that the syntax for the library was completely inspired by the work I saw done in Machine.Specifications (MSpec).

My main reason for developing developwithpassion.bdd was to have something that had the same syntax, that I could drop into my existing MbUnit projects and have them work side by side. This allowed me to take advantage of the existing unit runners (MbUnit Gui, MbUnit Console, Icarus, as well as TestDriven.Net), more importantly, it allowed me to slowly evolve my test writing style without having to revisit all of the tests that I already had in place. Of course, the library (being something that I use personally) has adopted a lot of things such as my naming conventions, as well as a fairly significant set of base classes that allow me to significantly cut down the noise in the tests/specs.

The Eleutian boys did a great job with MSpec, and I just wanted to make it very publicly clear as to where this project got its inspiration!!

Develop With Passion

Comments [0] | | # 
 Friday, March 06, 2009
Friday, March 06, 2009 9:52:00 PM (Mountain Standard Time, UTC-07:00) ( Tools )

A good friend suggested that “seeing your name at the top of all my tests is weird”!! To that end I am rebranding all of my common libraries to be prefixed with the develop with passion label. I have really put this framework through its paces and am really happy with the way that it allows me to write tests.

You can read about it on the following blog posts (just replace every occurrence of jpboodhoo with developwithpassion!!):

Develop With Passion!!

Comments [1] | | # 
 Thursday, March 05, 2009
Thursday, March 05, 2009 7:38:00 PM (Mountain Standard Time, UTC-07:00) ( )

I had someone a couple of days ago ask for my Visual Studio color settings. I got mine original settings by using the ones provided by John Lam. I did this mostly because of switching to vim and wanting to check out what his _vimrc file looked like. I fell in love with the color scheme and have been using it.

I can’t remember what (if any changes I made to mine) so I just went ahead and exported my current color settings.

You can download them from here.

Develop With Passion!!

Comments [5] | | # 
 Tuesday, March 03, 2009
Tuesday, March 03, 2009 3:41:00 PM (Mountain Standard Time, UTC-07:00) ( General )

Now that I am tweeting regularly, I thought it would be time to announce that the last couple of months spent heads down working on a startup have produced some rather interesting results. This is an informational post to let people know that I am going to be getting back to a regular schedule of blog posting interesting coding techniques. This is something that I have neglected for a while, being more concerned about getting people motivated.

While my goal is to continue to serve up what motivation I can, I want to start documenting some of the things I have learned over the past year, as well as getting back to helping people out (to the best of my abilities during this busy time!!). In the spirit of things, the first question I will answer on Thursday is:

“I am trying to create something that is capable of returning a strongly typed item out of my configuration source. The configuration source will initially be the standard web.config, but only as the web.config only holds string values, I would like for my configuration object to be responsible for casting out the appropriate type. My question Mr. Jean-Paul is how would I go about setting this up using Visual Studio 2008. would I go inside my already existing Web.config or would I build a new one for my core project? Thanks for your time and help.”

And no, I am not going to be showing how to use VS to generate it for me. I want to use it as an opportunity to demonstrate more BDD, with that example in mind. This serves a dual purpose. It gives people an opportunity to see how I would tackle the design and solution of the problem using tests as my design surface, but it also ensures that the person who asked me the question gets a solution whether or not they care about the testing aspect.

After too much time spent with my head down, allowing e-mail bankruptcy (previous post should have cleared that up), I now have a good (simple) system in place that will ensure people who are truly taking time to get in contact with me get a decent response. It also gives me an opportunity to get more code centric posts out there, as well as help people!!

Develop With Passion!!

Comments [0] | | # 
Tuesday, March 03, 2009 3:37:00 PM (Mountain Standard Time, UTC-07:00) ( .Net 3.0 | C Sharp | Programming )

I am currently working on a large winforms application (most likely the last winforms app before I make the transition to WPF). I am writing the application in a top down fashion, which means I drive out the tests for the presenters, and then move down through the corresponding layers to get a good vertical slice of functionality. When it comes to the development of the user interface I am using a command based UI to allow me to easily drive the testing of the screens easily from a unit test. One thing that I often need to do, is cause a UI component to trigger one of its own events to see if the command in question will be triggered. In order to allow for a bit of “guidance” I wrote a class that allows me to quickly trigger events on UI components. The following code snippet shows a usage:

EventTrigger.trigger_event<Events.ControlEvents>(x => x.OnKeyPress(new KeyPressEventArgs('A')), target);

I am making use of an expression tree to determine which event I want the target control to raise. This is easily done because most (almost all) UI components in both the .Net framework and 3rd party Winforms libraries follow a convention of having a method named “OnEventName” which is usually a protected method that the control itself can call when it wants to raise its event. The EventTrigger class lives in my test utilities and for my current application I have a set of Events classes which correspond to some of the third party, and raw .net, control I want to raise events on, here is a trimmed down section of one of the events class:

public class Events

{

    public interface ControlEvents : IEventTarget

    {

        void OnEnter(EventArgs args);

        void OnKeyPress(KeyPressEventArgs args);

    }

 

    public interface FormEvents : ControlEvents

    {

        void OnActivated(EventArgs e);

        void OnDeactivate(EventArgs e);

    }

}

Again, this class lives in my test utility folder and it contains interfaces specific to control types that I want to raise events on. For each control interface, I will place the events (as needed) that I need to be able to trigger from my unit tests. There are multiple ways to get the correct method signature on these interface methods, I can use the Object Browser, Reflector, or ReSharper can generate them!! The point is, the interface contains a public method that is the identical signature for a corresponding protected method on the target control. This is really to help get intellisense about the event I want to raise along with the arguments to the method itself. This works with all component frameworks as their EventArgs classes are always made public as to be able to be consumed by the components that will be hosting them.

Let’s get to the interesting part of this. I mentioned earlier that I am an expression tree to ultimately raise the event. Let's take a look at the trigger_event method signature to get a little understanding of what it is doing:

static public void trigger_event<Target>(Expression<Action<Target>> expression_representing_event_to_raise, object target) where Target : IEventTarget

Notice I am making use of the IEventTarget interface to basically simply constrain the incoming expression to be one based on one of the interfaces that lives in the “Events” class. The first argument “Expression<Action<Target>> is an expression representing the code. The target argument is the actual control to raise the event on. Here is the entire body of the trigger_event method:

static public void trigger_event<Target>(Expression<Action<Target>> expression_representing_event_to_raise, object target) where Target : IEventTarget

{

    var method_call_expression = expression_representing_event_to_raise.Body.downcast_to<MethodCallExpression>();

    var method_args = get_parameters_from(method_call_expression.Arguments);

    var method_name = method_call_expression.Method.Name;

    var method = target.GetType().GetMethod(method_name, binding_flags);

 

    Debug.Assert(target != null,"The target to raise the event on cannot be null");

    Debug.Assert(method != null,"There is no method called {0}, on a {1}".format_using(method_name,target.GetType().proper_name()));

 

    method.Invoke(target, method_args.ToArray());

}

This is test utility code, so I am able to make a lot of assumptions about how I am going to be consuming and using it. For starters I know that the ExpressionTree coming is is going to represent a MethodCallExpression. This post is only a small intro into the amazing concept of expression trees, if they are not something you are comfortable with, there is no time like the present to start playing around with them.

With a MethodCallExpression I have access to the MethodInfo object that contains information about the target method to call (this allows me to reflectively match upto the protected method on the target I want to raise the event on:

var method_name = method_call_expression.Method.Name;

var method = target.GetType().GetMethod(method_name, binding_flags);

Once I have the actual method to invoke, it still needs to be invoked with the correct arguments:

method.Invoke(target, method_args.ToArray());

The act of getting the arguments is the interesting part to this code (and a little gentle introduction to the world of ExpressionTrees for those of you who are not using them yet). The following line:

var method_args = get_parameters_from(method_call_expression.Arguments);

method_call_expression.Arguments is actually a collection of Expressions also. If you look back at the line of code that is using this the original trigger method, we’ll decompose it so that you can get a better idea of the expression tree created to represent the call to the event:

EventTrigger.trigger_event<Events.ControlEvents>(x => x.OnKeyPress(new KeyPressEventArgs('A')), target);

  • MethodCallExpression [x.OnKeyPress(
    • NewExpression[new KeyPressEventArgs(
      • ConstantExpression(‘A’)
    • )
  • )

Expression tree are “tree based structures. This simple line of code actually constructs an ExpressionTree that consists of a:

  • MethodCallExpression
    • NewExpression
      • ConstantExpression

Here is the complete code for the get_parameters_from method:

static IEnumerable<object> get_parameters_from(IEnumerable<Expression> parameter_expressions)

{

    foreach (var expression in parameter_expressions)

    {

        if (can_handle(expression)) yield return get_value_from_evaluating(expression);

        else cannot_handle(expression);

    }

}

This method iterates over each Expression in the incoming set and attempts to expand it to an actual object value. The can_handle method simply makes use of an existing dictionary that has been populated at startup with handlers that know how to evaluate the appropriate Expression:

static EventTrigger()

{

    expression_handlers = new Dictionary<ExpressionType, Func<Expression, object>>();

    expression_handlers[ExpressionType.New] = instantiate_value;

    expression_handlers[ExpressionType.MemberAccess] = get_value_from_member_access;

    expression_handlers[ExpressionType.Constant] = get_constant_value;

}

 

The get_value_from_evaluating(expression) method is very simple, it just look into the dictionary using the NodeType of the current expression, and invokes the expression handler against the expression so that it can be evaluated:

static object get_value_from_evaluating(Expression expression)

{

    return expression_handlers[expression.NodeType](expression);

}

Lets start by looking at the simplest one of them all, the method that evaluates a ConstantExpression:

static public object get_constant_value(Expression expression)

{

    return expression.downcast_to<ConstantExpression>().Value;

}

This method explicitly casts the incoming Expression to a ConstantExpression and then returns the expressions value. In our current example, that value will be the char ‘A’.

We’ll finish up by looking at the most involved one:

static object instantiate_value(Expression expression)

{

    var new_expression = expression.downcast_to<NewExpression>();

    var args = new_expression.Arguments.Select(constructor_argument_expression => get_value_from_evaluating(constructor_argument_expression));

    return new_expression.Constructor.Invoke(args.ToArray());

}

 

In the second line we are actually evaluating each of the constructor arguments expressions one at a time and having them also evaluated by the get_value_from_evaluating method. Because of the nested nature of expression trees, depending on the type of Expression that was passed in, this handles recursive traversal of the expression.

Once all of the arguments to the constructor have been evaluated, we can then invoke the expressions Constructor (which is a ConstructorInfo) to create the item. In our example here, it will cause the creation of a new KeyPressEventsArgs with the character of ‘A’ (the character was evaluated using the ConstantExpression we discussed earlier).

When it comes to testing a new control I can just create a new nested interface in my Events class, add public versions of the protected methods that I want to invoke (along with the correct arguments) and then I’m off to the races!!

Develop With Passion

Comments [1] | | #