This is the third in an ongoing series of articles about my team's transition to the Asp.NET MVC Framework.  In my last post I blogged a bit about how I haven't quite got comfortable enough with the new MVC framework to feel über productive.  What augments the feeling is the difficulty of finding quality information.  The data is few and far between and only sometimes relevant.

I was struggling yesterday to find information on the ComponentController class.  Things I was finding were from the Preview 2 release but finding something on the Preview 3 release was a bit more challenging.  Things are rapidly changing in the framework and the MVC team is not afraid to refactor, rename , or even remove a class.  For example, with the release last night, ComponentController is no longer a worry of mine because it's now gone, removed completely from the framework. 

The MVC framework has been around for under a year (Nov 2007 I believe).  It is now in it's fourth iteration (Preview four, released last night).  While a number of people have downloaded and are using the framework the amount of data/tutorials/blogs/articles pales in comparison to the same information about web forms.  This makes finding the info you need much much tougher.  It's exciting though and must say I enjoy the challenge.  The change in releases doesn't bother me.  It's a bit of a nuisance but I signed up for this trip.  Also the changes are for the better.  The ComponentController class that was replaced yesterday was not easily testable.  The MVC team removed it in favor of the Controller class, which is testable!  Fundamentally it boils down to the fact that I trust the guys on the MVC team and where they're going with the framework.

That trust doesn't help me day to day in moving my project forward though.  In order to find the data I need I've had to be both resourceful and thorough in my reading.  The trick I've found is following a few bloggers closely and reading all of their posts regarding MVC and all comments made to the posts (that's where I find the real gems, in the comments).

Here is a list of bloggers I'm following, obviously some are well-known, others are not.  If you follow some bloggers who post about the MVC framework that aren't on my list please share!! My list:

Updated to add new blogs (7/23/2008) ... thanks Ben

Yesterday I reported that I was learning to walk and while I can't quite say I'm walking yet,  I'm feeling a bit more comfortable.  My velocity increased ever so slightly today and I'm encouraged by that and excited for tomorrow!  And to be quite honest that's a perfectly find place to be.


 
Categories: .NET | MVC

I recently posted some code that could have taken advantage of format strings available when using the ToString() for integer output.  The other day I was building a report for a moonlighting gig where some of the text had to be right aligned and left aligned.  String.Format() does that as well.  I've seen some goofy attempts at formatting text, presumably not realizing the makers of the framework built it in.

Check out the code below:

   1: var phone = "319-585-6594";
   2:  
   3: Console.WriteLine(string.Format("{0,20}", phone));    // right aligned
   4: Console.WriteLine(string.Format("{0,-20}", phone));   // left aligned

Which produces:

image

Next time you find yourself calculating lengths of strings and prepending/appending spaces and/or padding stop and take use of what is already provided for you.


 
Categories:

A few days ago I posted that our team was making the transition from webforms to MVC.  Since then a few days have gone by and I wanted to post my some struggles and successes (however few) in recent days.

First, it's been tough wrapping my head around the shift from web forms to MVC.  I would caution anyone making a similar shift or considering it, that despite the recognized short comings of web forms and the postback model that one should approach the change expecting a bit of a rough going in the beginning.  Never underestimate what years of articles, blogs, and webcasts about web forms and working in web forms will do to your perspective.  OnClick...gone.  PreRender...gone.

Does the experience thus far cause me to regret the choice to go MVC route?  Absolutely not.  It was 100% the correct decision.  Despite the difficulties of making the shift, there are points where something clicks and it feels better and more natural.  I'm waiting for that shift and those clicks to be more permanent.  The best analogy I can use to explain it is likening the experience to my one year old son who is learning to walk. To him crawling feels right.  When crawling, he's quicker, self-assured, and can generally get where he wants to go.  When he attempts to walk however, he falls down, he struggles to keep his balance, and generally getting anywhere takes longer.  It's temporary though, we know it and that's why we encourage him to walk and push through the awkwardness. In a few years Lincoln will realize (if not verbally but by the way he chooses to move) how much more natural walking is than crawling, a fact that I'm reminded of every time I get down on all fours with Lincoln.

So what am I doing to push through?  First I'm trying to keep in the project.  With smaller tasks and projects always requiring attention, I'm trying to stay in the project as much as possible.  Secondly, I'm thinking about how I think (Metacognition).  Thinking about MVC, testability, loose coupling and other such principles only aid in the transition.  I'm hoping the next two days this week give way to breakthroughs.  Near the end of the day I had some small wins and started to gain some velocity which leaves me optimistic for tomorrow.


 
Categories: .NET | MVC

July 14, 2008
@ 10:52 PM

Last week I blogged a about Unappreciated Open Source projects.  In the post I made a commitment:

From here on I've resolved to donate a dollar any time I download a free library or webcast where a donate link is presented.  Why $1?  In all honesty it is something I can commit to.

I'm thoroughly looking forward to watching the Summer of NHibernate next week while on vacation.  As I was downloading the videos I came across the "donate" link so I whipped out my Paypal account and made good on my promise.

image


 
Categories: Open Source Software | ORM

We recently decided that with the effort we're putting into our website and some changes that we're making that now would be as good of time as ever to make the switch to the new Asp.net MVC Framework.  We're no Google, but we're currently receiving around 18,000 unique visitors a day and 300,000 page views and hope to grow that number as we make our site easier to use for our customers.  I hope to rely heavily on Phil, Rob, and Scott for assistance if needed. 

The MVC design appeals to us because the large amount of business logic that has crept it's way into the codebehind.  Despite the best intentions, the current site, which is programmed in asp.net 1.1, has had too much logic to creep into presentational areas while running with webforms.  The biggest drawback to this is reduced testability.  Testability should be important in any project but for us it is paramount. We have business rules that if not adhered to amount to real-world fines:

A few years ago a customer bought some lubricant that is sold in an aerosol can.  Since 9/11 aerosol cans cannot be shipped as cargo on airplanes.  Somehow this order made it though the checks we have for this type of thing in the warehouse and made it onto the UPS truck.  At the UPS facility, a UPS employee heard something emanating from a box that sounded like an aerosol can.  At that point he is required by law to check the contents.  When he opened the box he found the aerosol cans.  Despite knowing us and our reputation, he was required to call the FAA and say something to the effect of, "I found some aerosol cans in a package that was scheduled to be flown."  It didn't matter that this was an accident or "just a few cans", we were still fined.  We were warned that if this were to happen again that we would face a fine somewhere in the low six figures. The FAA doesn't mess around.

As we go forward I plan to document on this blog the highs and lows of our transition.  I'll post questions and problems we're having that I hope you can help with as well as tips and tricks our team has found helpful.  Stay tuned as we make the transition.


 
Categories: .NET | MVC | Software

A coworker ran across the following and shared with me.

   1: Dim strpage
   2: strpage = pageNumber.ToString()
   3: If Len(strpage) = 1 Then
   4:     strpage = "000" & strpage
   5: ElseIf Len(strpage) = 2 Then
   6:     strpage = "00" & strpage
   7: ElseIf Len(strpage) = 3 Then
   8:     strpage = "0" & strpage
   9: End If 

The programmer is trying to ensure that the page number, when printed out, is always four characters long.  This is not the best way to write this code.  I thought I'd keep this post to myself but unfortunately this isn't the first time I've seen code like this, it is quite common.

The better way to write the above is:

   1: Dim strpage
   2: strpage = pagenumber.ToString("0000")

It's shorter, more concise, and easier to read.  Further the second example is more extensible.  If the requirements change to say the page number should be five characters, the first example must recompile.  The second example must be recompiled as well in it's current state, however the string "0000" could be moved to a configuration file somewhere and then wouldn't need to be.


 
Categories: .NET | Programming

Chris Sutton tagged me yesterday asking how I got started with programming. So here it goes.

How old were you when you started programming?

I suppose I first started with my TI-86 in physics class making text based adventure games.  After that it was HTML and building a website on geocities (remember them?).

What was your first programming language?

HTML, if you count that, otherwise Pascal.

What was the first real program you wrote?

I wrote a small portion of an application in VB6 for a local paper company while I was an intern in college.

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

Yes, most definitely, and would kick myself for not taking advantage of the abundant resources and time while in college.

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

First, have passion for your craft.  Second focus less on languages and specific technologies, but instead focus on principles and core fundamentals.

What’s the most fun you’ve ever had … programming?

In college I wrote my own compiler for an honors project and I used to stay up every Thursday night and program in preparation for a Friday morning meeting with my advisor.  About 2am I'd make a run to the local grocery store and buy some Mt. Dew and a box of Nutty Bars.

I'd like to hear from:


 
Categories: Musings

July 9, 2008
@ 09:13 PM

Many people use open source tools, whether its NUnit, Nant, Rhino, or log4net in their professional lives.  If you use any of these tools, when was the last time you donated time and/or money to any of the open source tools you use?  That's what I thought. 

I was recently watching the Hibernating Rhinos from Ayende Rahien and I wanted to thank Oren.  Right there on the Hibernating Rhinos page it reads:

donate

I wanted to donate.  Perhaps because the videos provided so much guidance from one of our industries finest.  Perhaps because I've met Oren and generally think he's a good guy.  Regardless, I donated some money.  Not much, but some.  Something to say, "thank you, I appreciate this.

Curious if other donate, I emailed Ayende to see what revenue, if any, his video series has generated.  I wanted to know well the community was supporting a popular training tool.  Here's the stats, lifted a few moments ago.

image

So how much has Oren received from this video series?  Guess.  Seriously.  $125 since September 2007.  From the stats above there have been 242,610 downloads of the videos. That breaks down to .000515 per download!!!  As a community that's quite pathetic.

From here on I've resolved to donate a dollar any time I download a free library or webcast where a donate link is presented.  Why $1?  In all honesty it is something I can commit to.  I download and use a lot of tools, so I don't want ongoing cost to hinder me.  $1 is a token to say thanks, acknowledging the work that's been put into the product.  I would challenge you to make a similar commitment for the tools you use.  Let's show the author(s) of these tools/libraries that we do appreciate the work they do!


 
Categories: Musings | Open Source Software

About a month ago Jean-Paul Boodhoo announced a contest that he was sponsoring.  The contest idea centered around the idea of developing passion in others around you.  I have an immense amount of respect for JP having met him at ALT.NET Seattle.  When the contest was announced I thought I'd put in an entry as I enjoy the journey passion for my craft has taken me on with others.  Here is my entry in its entirety:

While I'm not quite sure that my entry will be legal - a bit on that in a second - I would still like to share my story.  As for the legality of my entry, the rules clearly state "Must be working full time as a software professional (not a student)" (emphasis mine).  While I am a full time software professional, I must say that I am, unequivocally, a student.  We all are, whether we realize it or not.  The one truth I keep encountering in my maturation as a developer is a bit of a paradox: the more I learn, the more I realize I don't know.  Therefore I approach software development as a student and view my coworkers as students as well.


When I started at my last place of employment I was humbled early and often by my lack of knowledge in areas I thought I knew well.  Rather than being deterred, it sparked a fire in me, and since then I've never turned back.  Being humble and realizing, for lack of better words, how stupid I was, was quite possibly the best thing for my maturation as a software professional.  That spark has matured into a passion that I can best describe as the feeling of a child on Christmas morning, eagerly shaking his sleeping brothers and sisters telling them that Santa has come.  It's the type of knowledge where you share it not to show how much smarter or better you are, but because you are, at your core, excited at the chance to share it with someone else.


Among things like reading blogs, starting a blog of my own, listening to podcasts, I started to teach more. There are a great many people who believe that the best way to learn is to teach others.  I fall squarely in that camp.  I began by timidly teaching a few of the weekly developer trainings that the company offered.  Soon, I was teaching quite regularly and in 2007, I taught more than anyone else in the company.  I focused many of my talks on areas where I struggled and on things I wanted to learn, realizing that if I struggled learning a concept/language/framework, others probably did as well.  In one training session I created an elaborate hands-on demonstration of how events and delegates work.  Participants were given a card stating what they should do when a specific event occurred.  It started innocently with me turning off the light switch and, at it's height, had people walking all over the room, some making marks on the white board, others moving objects around the room, and still others doing various assigned tasks.  I was told later by someone that, "...it was the best training of events and delegates they ever had seen."  That comment was special to me. 


Why do I think I deserve to win this contest?  Honestly, I don't know that I do.  I'm not an "alpha" type, I haven't produced tons of tutorials or webcasts to help the community, and most of you probably have never heard of me.  However, I believe that if you ask current and former coworkers, they would say that I seek to help and mentor others as well as offer myself up to be mentored.  To me, more than having a large internet following, I desire to impact those around me.  Below are two recent such examples.  The first is an email I received a bit after I left my last place of employment:

Hey Tim,

How are you and howz your new work? Hope you have settled down.

Here same as usual , I got to take your big desk J yeeeeee . Josh A is sitting at your place with my small desk.

Hey listen thanks for introducing Rhino mock , I am getting better at it and I like it ….

Usharani Kachegere

The second example is is from a younger developer, Toran Billups, who emailed me one day out of the blue when he saw that I updated my alumni page on our college website.  Toran emailed me innocently one day asking about my work experience.  We started chatting more and more and I provided whatever guidance I could to him.  I have enjoyed my time mentoring Toran, as it's been a bit more focused with one-on-one time.  I've gotten the chance to see him grow in his skill, and more importantly, his passion.  Below are some of his comments about his experience over the last year and a half in a recent chat:

"I think from the moment I 'emailed you' to ask for some 'mentor like advice' you have shown a true passion for software development/learning/etc."

"your words have pushed me to a level I only dreamed of 11 months ago"

"I'm knee deep in TDD and in part because of your words!"

"I just built a house - otherwise ... i would move just to work with you- honestly"

"it's like something happened after talking to you last year ... I never had anyone challenge me like you did"

"but again - without your 'patience' / 'care for others in the community' -- you could have brushed me off with a simple 'newb' comment instead - you took the time (out of your busy day) to help ask the 'right questions'

If you're reading this and you've found yourself losing passion for your craft, family, or faith, don't sit idly by.  Do something, anything, to get back into it.  Do what whatever it takes to reawaken your passion and foster that passion, you'll be much happier person for it.  I wrote last summer on my blog about passion in a post titled "Passion in Programmers", and I believe what I wrote in that post to be as true today as the day I wrote it.  In it I wrote, "Passion in my mind is a key characteristic of being a great developer.  A passionate developer will never stop learning and enjoys the journey of learning and thus is an asset to any team."


 
Categories: Musings | Programming