Sunday, August 17, 2008

eRubyCon takeaways

I had the pleasure of attending eRubyCon here in Columbus Aug. 15-17. This is the second year for the event organized by Joe O'Brien, and the first year I got to attend. Josh Holmes has put up great reviews of the sessions up on his blog.

Since I don't really want to repeat Josh, what were my takeaways from the event?

First, that I still need to get more involved in Ruby. This is just a cool language that allows you to do so much as a developer. The allure of RSpec aside, it just reads well and makes sense. So, a couple things came to mind as near term goals. First, I need to start with some simple scripts for everyday tasks, and write them in Ruby. Second, I'm going to try to wire up IronRuby to test some of my C# hobby code. Doubt I want to drag that one into the office just yet. Those two items should get the ball rolling for me.

Second, and I think the larger takeaway for me, was that the .Net community was almost totally missing. I noticed this in two areas, there were very few .Net developers in attendance, and most of the topics only recognized that Ruby people were converting from Java. There was a lot of Java venom being tossed around for that reason, but the opposite of love isn't necessarily hate. It's apathy. The .Netters took it on the chin in the apathy department.

What can we in the .Net space do about this? First and foremost, get out there and see what else is going on. There is a lot of software not written on a Microsoft platform, what can you learn from them? I'm not saying learn something top to bottom, but get ideas from others. In the end, language doesn't matter as we're all trying to solve people problems, and the better armed you are to solve those problems, the better off we are as a whole.

Before I lay all this at the feet of the .Net community, those outside the Microsoft environment have a little responsibility here, as well. When Michael Letterle and Josh Holmes were up to give the IronRuby, Silverlight double header the room cleared a good bit. For the same reason the .Net folks should look outside their comfort zone, maybe others should take the chance to look inside the big blue monster to see what's happening.

I'm well aware of time constraints and family and "I'm already learning seven other things!" and a reading list that's growing faster than it's shrinking. But, instead of hitting your fourth Day of .Net in a row, take in a Ruby or Python conference. Or, if you're already at a Ruby conference, stick around and see what IronRuby is bringing to the Microsoft and Ruby communities.

One of my favorite terms of late is Jim Holmes's "Specializing Generalist." Looking inside or outside the Microsoft space, as the case may be, will add to the Generalist side of the equation. And, who knows, may change what you decide to be a Specialist in.

Wednesday, July 9, 2008

TDD Starting to Sink In

Back in late March, I blogged about my issues getting going with TDD. At the time I was nearing the end of a project where I had attempted some unit testing, but had not done it up front. I was looking forward to a clean slate to get some more work on TDDing up my code.

That opportunity somewhat presented itself, though I was moving on to an established team, which presents its own challenges. However, this team, or a good portion of it, was practicing TDD. So, plenty of example code out there. Not only that, I ended up sitting about 3 feet from world renowned TDD zealot, Steve Harman. Steve is a great teacher, and only yelled at me a few times. (And I only cried the one time...)

That helped on the professional side of things, but even in my own hobby coding I started writing more and more tests before the code. I've been presenting on ASP.Net MVC at a few places recently, and the sample code I use there was written all TDD style. (And is presented test first.) Well, almost all of it...somebody wrote his repository wrong, and the updates didn't work so well. I have some refactoring to do.

So, here I am 3 months later, where do I stand on the points I brought up back in March?

1. I tend to wrestle a lot with when to layout some of the framework and when to just breakdown and write the tests.

This one became pretty easy when Steve introduced some BDD (Behavior Driven Design/Development) style grammar to our testing. This one shift in thinking opened up my ability to get the requirements into unit tests, and get them green quicker. In a nutshell, thinking along the lines of, "When X condition is present, then Y should happen," and naming the classes and test methods with that type of grammar took me well beyond wondering when to write the tests.

2. A recent project found our team working with a pile of generated tests.

Generated tests are a thing of the past. This is a non-issue at this point.

3. When to mock?

Again, a healthy dose of Steve helped here a lot. Also, Rhino Mocks 3.5 was released with the Arrange, Act, Assert syntax, and that cleared up a lot in the mocking area. No more record and playback blocks, and lots of lambdas to stub out that which you want doing the dirty work.

The answer to the original question finally became clear: Get the hard stuff out of the way with mocks. Beyond that, get the stuff that you're not testing out of the way with mocks. The AAA syntax made that pretty easy.

4. Is this test trivial, or needed?

OK, I still have a bit of trouble here. Not as much as before, but occasionally I find myself writing a test, looking at it, and going, "Gee, I'm testing the setter of that property...that had BETTER work!"

5. I still have large holes in what I test.

Again, still having trouble here. Even with the good TDD practices in place at the most recent project, I found myself frustrated and writing the code and screen testing it rather than writing my unit tests up front. I did have a deadline that I was up against, but cutting the unit tests is never the right solution. I fell back to an old habit, one I've been working pretty diligently on breaking.

In the March blog entry, this referred to unit testing my javascript. Well, ending up on a Webforms project pretty much ended my worries about getting my javascript tested.

So, with those steps behind me, what do I want to focus on now? Well, I can still improve on numbers 4 and 5 above, but I think those two will be continuous improvements. I'm going to continue down the BDD-ish path. It's not pure BDD, but it got me over the hump, and I like the syntax. But overall, I'm just going to keep going at getting the tests written up front. Focus more on the red, green, refactor as much as I can. I'm seeing the benefits, just need to get those old habits kicked.

Tuesday, June 17, 2008

The Summer Tour of Timbo

The summer speaking tour is about to get underway, fresh off the heels of my successful spring tour. (Successful after the QSI Tech Night unit-test-a-palooza fun.)

We'll be kicking off the summer tour in Cincinnati next Tuesday (6/24) at the June CINNUG meeting. I'll be presenting on the ASP.Net MVC framework, why it's cool, why you should be using it now, and how it will do simple household chores for you - walking the dog, doing the laundry, and cleaning the bathroom. (It doesn't do windows, though.)

Fresh off the evening in Cincinnati, I'll be heading to Dayton the very next evening to present the same riveting and engaging presentation to the good people of the Dayton .Net Developers Group. Fellow Quickie Jim Holmes helps run the Dayton bunch, so I expect heckling in Dayton.

Following the quick bang-bang trip across south western Ohio, I'm off for a few weeks before I head below the Mason-Dixon line to speak to the Memphis .Net User Group on July 24. "Memphis?!?!" you saying. Jeff introduced me to Colin Neller, president of MNUG, when I was in Vegas for Mix, and he invited me down after I expressed a little interest in getting out to do some speaking. My topic in Memphis is as yet undecided. Colin has a poll up in the MNUG forums for either an MVC deep dive or my Evangelizing the Pragmatic Programmer talk. Can't wait to see the results. It's 50/50 at the moment, so if you're in the Memphis area get your vote in...you could be the deciding vote!

That ends my scheduled trips at the moment, who knows what I'll rope myself into as August comes along.

Monday, June 9, 2008

How I got started programming

I got called out by Jeff in his post on the same subject. I believe this idea can be traced back to Michael, and it's a pretty good idea. It's nice to see how our friends and colleagues have progressed.

Fair warning, this could get long winded. I am, after all, talking about my favorite subject...me. :)

How old were you when you started programming?
I think I was 12 when I first wrote some kind of program. Christmas of my 7th grade year, Ma and Pa Wingfield bought an Apple IIe, along with a couple games. However, I quickly got bored with the games and wanted to make that machine do the stuff I wanted. I talked mom into springing for the 128k upgrade card, and I got down to writing some BASIC programs.

Between the 7th and 8th grade, mom actually sent me to Ohio State to "Computer Camp." It was like Code Mash '83. A bunch of 12-14 year olds on OSU's campus for a week writing code. Oddly enough, at the time I was an "Apple Guy" because that's what we had at home, but all the machines at the camp were IBM's. So, I basically just focused on the BASIC code, and not all the screwy graphics stuff that only worked on the IBMs.

How did you get started in programming?
Through High School, I did very little programming. Females and football were my main focus, and after graduating I was off to OSU to get an Ag Econ degree. While at OSU I did take a beginning programming course, and it was one of the few courses I enjoyed. (Didn't take the hint, though.) In it, we were writing PASCAL on Macs...back to the Apple. (The irony is getting thick, here.)

After that class at OSU I let my programming gene slip again, and didn't really take it back up until I got a 486 in '93. After getting that, and with the web boom right around the corner, HTML and javascript were intriguing, so I hobbied around with them for a while. Then, got serious and went to Franklin to work on getting a CS degree. That's when it all started to come together and I figured out I really was a computer guy at heart. (At FU I did most work on a UNIX system...no Apple this time, but no PC, either.)

What was your first language?
As noted above my first language was BASIC on the Apple. Lots of GOTOs in my code, too. Nothing brought my 128k expansion card to it's knees quicker than a nice infinite GOTO loop.

What was the first real program you wrote?
This is kind of a two parter for me. The first large program I got working was a Stock Market simulator I copied out of a magazine. I made a few minor tweaks to it to make the stocks move faster and change the companies that were traded.

But, the first real program I wrote from scratch was a farming simulator when I was in the 8th grade for the IIe. I grew up on a grain farm, and decided to write a simulator for planting, harvesting, and trading grain. I titled the program "Appleculture" which I thought was pretty snappy. The most difficult part of the game to program was the random number stuff to make the grain prices move, but not move too much. And to make them trend up or down, not taking huge jumps in the opposite direction it took the turn before. It got pretty involved. It also had a banking portion to it, so I guess I was staring my "line of business app" future square in the face there and didn't even know it.

What languages have you used since you started programming?
Hmmm...BASIC, PASCAL, C++, Java, VB 5, HTML, Javascript, ASP, VBScript, PHP, C#, VB.Net, Ruby (just getting started on that one)

What was your first professional programming gig?
First professional programming gig was at a small lighting manufacturing company near the airport back in about 1997, I believe. I was brought in to build the website, oversee the computer systems, and do some other things around the building. Turned out the guy that owned the company wasn't all that good at delegating, so it ended up being more of a production manager position than web position. I did get the website launched before I left, and it was still the web site up until about 18 months ago. (Which is really kind of sad.)

If you knew then what you know now, would you have started programming?
Yes. If I knew then what I know now, I would have started focusing on programming much sooner. My real programming life didn't start until I was about 26 or so, even though I was writing random grain price generators when I was 13.

If there is one thing you learned along the way that you would tell new developers, what would it be?
I'll have to follow the crowd and say soft skills is a big one. Everything is a people problem, so to solve those problems you've got to deal with people. If you think fixing the problem is locking yourself in an office or hunkering down in a cube for endless hours typing away, you're mistaken.

Secondly - can't narrow this one to just one - and I read this in somebody else's post and heard it from Brian Prince, get a mentor or mentors. After leaving the small manufacturing place I've been lucky enough to have at least one person at each company that's been a mentor to me. At Quick it seems I'm surrounded by mentors. In this chosen career you're always learning, if you're not always learning YOU are the problem.

What's the most fun you've ever had ... programming?
Not sure I can narrow down a "most fun" time, but my most satisfying time was working on the MCCH project for the Attorney General's office. Simplified explanation, this was the web interface for the Amber Alert system in Ohio. My email address is still in the db for all Amber alerts in the state, and seeing, "Alert canceled, child recovered," come into the inbox always makes me feel good.

Jeff called me out, so I'll pass along the call outs. Like to hear the stories of...

Jim Holmes

Greg Finzer

Phil Jordan

Steve Horn

Matt Casto

Sunday, April 27, 2008

So much to blog about...but I'm on VACATION!

I've got so much I should be writing about. Considering I just spoke at Central Ohio Day of .Net and at Cincinnati Financial's .Net User Group just over a week ago, there are a couple of wrap ups due there. Also have a little jQuery with MVC that I'd like to blog up. Actually, I should have a few more MVC posts coming out.

HOWEVER!

Tomorrow at 7:10am I get to fly to Orlando with my youngest for a trip he doesn't know about yet. Big surprise for the five year old will hit tomorrow morning.

With my Blackjack II loaded and ready to go, there will be tweets from The World, I'm sure. I tried to get Windows Live to accept photos, but couldn't get it to work. The emails all bounce back and the photos never appear. So, Google to the rescue, and I've got a mobile blog all ready to go, complete with a before picture of the unsuspecting Alex.

So, this short trip to see what Mickey and Donald are up to will be used as a moblie computing experiment. OK, maybe not so much an experiment as three days in my favorite vacation spot with my son and my still fairly new found mobile universe. Should be a lot of fun.

Saturday, April 5, 2008

Video on ye ol Blackjack II

Got a short trip coming up soon which will involve me and my youngest, Alex, hopping on a plane for a couple of hours. Being tech-ish, and wanting to pack light, I figured I'd get a couple of episodes of Spongebob from iTunes, and we'd have one entertained 5 year old via my Nano.

But, the Nano has one small screen. And, hey, look at that...the screen on my Blackjack is about TWICE as big! Light bulbs go off everywhere...

Went something like this...

- Blackjack runs Windows, and has windows media player. I've got a ton of .avi movies, let's load one up!

[Failure]

- OK, it's a stripped down version of media player, we'll just convert that sucker to a .wmv file and we'll be in business!! Google up a video converter and find Prism. Free, and does the trick. So, about 90 minutes later...30 minutes for the conversion, 60 minutes for Vista to kindly copy it to my Blackjack...we're pressing play on the Blackjack.

[Failure]

- Mother puss bucket...in a moment of weakness, I email fellow BJII noob Harman. I figured his newly bestowed MVP status has given him great powers over all things Microsoft. It did, "Email Keith Elder, he's the mobile wizard."

- I email The Elder, who promptly replies with, "Yikes, that's the one thing I've never tried on my phone!" Keith did direct me to another converter, Pocket DVD Wizard. This one is $25 with a free trial, which I snagged as it will give me 5 minutes of a movie converted to the format I need.

- Fire up Pocket DVD Wizard, which asks what device I'll be using. Select Samsung, and the secret is revealed: The file type needs to be .3gp. With the conversion complete, I copy 5 minutes of Toy Story to the Blackjack, and...

[Success!!]

- Short lived success, though, as it will only play in a tiny window. Flipping it to full screen makes it very pixelated and choppy. The window it plays in is smaller than that of the Nano, so back to square one.

Well, back to square 1.5. We're now converting a couple of those .avi files to .mp4 for the Nano. I figure the 4GB Nano will get us to and from Orlando, keep Alex occupied, and I'll use my Blackjack as an mp3 player for myself.

Assuming I can get that to work...

Oh, and Alex has no idea about the trip, it's a big surprise for him. Don't tell him!

Sunday, March 30, 2008

TDD growing pains

I've understood and attempted to follow TDD practices for a while. The initial understanding of it was pretty tough, and very, VERY sporadically put into practice. After all, it's a pretty big shift in thinking when you first encounter it. "Write tests? For code that's not there?? Wow, that's fantastic!!"

So, over time I've gotten much better at the whole TDD thing. Or so I had thought.

Wednesday, mid-presentation, my lack of patience with the system outed me. I had written my tests, passed my tests, changed my code, changed it a little more, and then went to present it. Wow did I get smacked in the head by not running the tests after each change. (Continuous integration for a small demo app didn't really enter my mind. I have a hard time firing up CI at home since there's not much to I, but maybe I should join Mr. Donaldson in doing so.) So, big time lesson learned there.

The flip side to that bit of a stumble was the amount of time TDD saved me on my current project at work. I had written a number of unit tests to cover some business logic, and a few integration tests. A couple of defects came in showing that I needed to change a number of my dates to nullable objects. Not a difficult change, but not totally trivial, either. Made the changes, ran the tests. Oops...more changes, ran the tests. The whole change over was done, tested, and passing within 15 minutes.

A few pitfalls I've fallen into while traveling down the path towards TDD enlightenment:

1. I tend to wrestle a lot with when to layout some of the framework and when to just breakdown and write the tests. The main reason I wrestle with this one is that the good ol' crutch of intellisense sure comes in handy for test writing if you've framed your code out some. (When writing Ruby code in e, this doesn't seem to be as much of an issue for me.)

2. A recent project found our team working with a pile of generated tests. With the ever present deadline looming larger and larger, we decided to go with the generated tests as they appeared to be "good enough." They were good at the start, but as the code base grew, and our tests with it, we started looking at our CI build taking up to an hour. There's a big red flag. Dug into the code, very few unit tests were generated, but a pile of integration tests were. Takes a while for nHibernate to do its thing 4,316 times. (We've since started cleaning that up, build is back to a more reasonable, but still outrageous half-an-hour now...)

3. When to mock? I'm hip to the whole mocking thing, but identifying the right time to do so is still giving me troubles. I'm sure I'll get there with practice, just need some more practice.

4. Is this test trivial, or needed? In a previous post I mentioned viewing code coverage the other way around, seeing what's uncovered rather than covered. I don't see 100% coverage, er I mean, 0% uncovered as attainable in the web projects I usually work on, but where do you draw the line? If you end up falling over on a piece of untested code, I guess it wasn't trivial.

5. I still have large holes in what I test. Just about all of my javascript code is completely untested. I know there are frameworks available to help me with that, but I haven't gotten down and dug into them.

So, short term I'm going to keep the ears pinned back and keep moving forward with the testing first. May as well get a home build server set up, and keep digging on mocking as much as I can. Gonna have to investigate Moq, as well. Also, time to get that javascript tested. With as much AJAX as we're cranking out, this is quickly becoming a priority.