Friday, July 31, 2009

2 week review

Normally this should have been a number of posts but I've been a little lazy on the writing front and busy on the "doing" front. I'll try to do better.

but first a message from our sponsors

So I can stop with the oblique references to "a system here at work" I'll call a spade a spade and now refer to my MVC application as iDEV because, well, that's what it's named (not my first choice in names but that's where we're at). And I'll stop with "it does stuff" because no one is reading this save myself and even if they were, they're not about to run off and steal all my ideas and build "the next big thing." What I've done has been done before and done better. Moreover, if you're stealing from me you're stealing twice.

there is *way* more to this testing thing than i thought

My last post was more prescient than I would have thought possible. Writing tests is...actually it's sort of interesting. There's a lot to do to be sure (more on that later), but the whole notion of thinking about what it is you want, writing some tests, and then implementing until they pass is fairly gratifying. At least in the sense that something didn't work and then does because, see, I have all these little tests that tell me so. It's also a metric fuck-ton of more work to do.

When I started with Rails I more or less skipped the whole testing framework. Wish that I hadn't now, but at the time it was way more fun to whip out features. So when I set out to learn ASP.NET MVC/redesign iDEV I was committed, to the extent possible to do it the right way - testing, testable patterns, and layers man, layers! What I didn't have an appreciation for, at least w/r/t to writing unit test vs. integration tests, is how much goes into making that possible. Especially all the things I have to learn. To be able to test these things in isolation means learning testable patterns, understanding how and what should be tested, and then understanding when to stub/fake things and when to use a mocking framework (in my case Moq).

Its been challenging to be sure. The only thing that's sort of driving me nuts is the the repetitive nature of the tests I'm writing. Given your typical Create action on a controller - I have to write a test to verify the view isn't null, returns the right model type, redisplays on an invalid model, and saves and redirects on a valid model. And that's just for one action in one controller (and I'm probably not writing enough tests there as it is). I still have to write essentially the same code for each create action in each controller - and I have a lot of controllers.

So I could make the argument that I know that I've implemented the controller actions correctly (since they're all mostly the same) and can now skip all those tests. Which would defeat the whole notion of writing tests in the first place. So I'll keep at it. Lot of work though. Especially when you think about how much visible stuff you could be implementing if you weren't writing all those tests. Best not to think too much.

the new hotness

It's always fun learning something new. No matter how trivial the item, it's something new that you didn't know before and now you do. But there's also the frustration. The "why the fuck won't this work?" - I'm following the example to the letter...no wait, I forgot that line. There, now it works. Frustration and reward - the lifecycle of the developer.

Trying to do things "the right way" on this project also means new things beyond just the framework. Things like Moq and StructureMap for dependency injection. Which, while it is incredibly cool and I understand conceptually how it works, I still don't entirely understand. Even spent a few days trying to make it work with version 2.5. All the code samples I could find were for prior versions with deprecated methods. Thank god for this article. Frustration and reward.

So to sum up, learning ASP.NET MVC means learning:
  • The framework of course
  • Moq
  • StructureMap
  • TDD/BDD
  • Linq to SQL
  • Testable patterns
It can be a little much sometimes.

things from my dome-piece (b/c thoughts might be giving me too much credit)

So a while ago I had this post outline talking about the differences between Rails and ASP.NET MVC. I think it's worth going over. Rails was dead easy - ruby script/generate Scaffold Product name:string and you had a model, controllers, and views for basic CRUD operations on a Product. There is way more plumbing that goes into ASP.NET MVC to accomplish the same thing b/c it [ASP.NET MVC] lets you choose how you implement your models. In Rails there was only the way. Play by those rules and your life rocks. Validation with a few lines, relationships with one more. Pretty cool indeed. I mean you still had to write the tests but you can't win them all.

So Rails development was fast to say the least. ASP.NET MVC offers some scaffolding features similar to Rails but not quite all of them. On the other hand, b/c Rails offerered only "the way" the only thing you really learned was Rails - or at least the Rails way. With ASP.NET MVC you have to make decisions, decisions that aren't necessarily well informed b/c, remember, you haven't done this before. And b/c there are decisions and alternate ways of doing things there is what I'll call tangential learning - things that are applicable outside of the current problem domain. Things that will serve you as a developer when ASP.NET MVC and the current project are long forgotten.

Frustration and reward.

Sunday, July 19, 2009

the corruption of youth

I'm sorry Aunt Darryl - I truly am. But like a crack dealer, I'm just serving a willing populace.

the backstory

So the whole climbing thing isn't terribly popular thing in my family. Sure people find it interesting, but hey, I'm not their kid.

Fast forwarding slightly, my considerably [?] younger cousin Max is living with us for the summer. He's been nothing less than an ideal guest. There may have been hope that I/we would be a positive influence. There was probably the [faulty] expectation that between Jennifer, Lauren and work there just wouldn't be time - or at the least, inclination. Sadly, for some, there was plenty of both former and latter.

a recent anecdote

So we (Bruce and you humble narrator) took Max out last week for some bolt clippin' at Roadside. Minus the torrential rain that cut the day [slightly (and quickly remedied by wings and beer)] short,we had a terrific time. And then, the phone calls started.

"So how was climbing?" asks my mother.

"Fine." I reply.

More questions follow eventually circling back to question #1.

"You know Mom, you've now asked more climbing-related questions in the past 15 minutes than you've asked in the past 15 years of me climbing."

"I know. I was just worried."

"He's still alive. Promise"

less exposition, more action

One week later and it's shaping up to be a beyond-perfect weekend at Seneca. Max is interested in something, ahem, bigger, and Bruce is interested as well. In particular, Bruce's attendance will mean that Max can gain the summit on some more interesting ground than Old Man's Route.

The parking lot is empty (deceptively so we'll come to find) when we arrive shortly before 10. There is some debate on the best way up. Bruce is pushing for the Ecstasy Jr. - Le Gourmet - Front C - Critter crack linkup. I'm down with most of that but want to start all the way down at Skyline and do the casual East Face linkup - mostly because it more or less follows the way I went my first time at Seneca. I have a distinct memory of doing those 3 pitches, having no idea where I was while turning to Andy and asking, "Are we at the top?"

Bruce demurs and we make our way up the East face trail. Skyline is coming into focus...doesn't look too bad...and then resolves into chaos. We turn around and head for the Stairmaster. We briefly consider Vegetable Variation and just as quickly discard it.

Between an in-shape Bruce and a young and in-shape Max (yeah, I just did that Bruce) I quickly fall behind. In short, I get thoroughly pwned. Max pats me on the shoulder like a supportive parent (or child with his grandfather),

"It's OK" he says.

A few minutes later we hit the bottom of Le Gourmet with a party already on it. I look at Bruce knowing that if we'd headed here directly/me not dying on the Stairmaster, we'd be on it.

"Sorry" I apologize.

"I wasn't going to say anything" he replies.

We make our way North and eventually settle on the first pitch of Monkey See, Monkey Do. Bruce blasts up with barely a pause at the crux and is at the belay in no time - pleased to see that it's a decent pitch despite his memory of it. Max works his way up next with just a bit of effort at the crux. I pad up last and make my way across the ledge to Front C.

My running joke about Front C is that I climb it in one of two ways - gracefully or desperate clawing. I make my way up and at the crux nearly lapse into desperate clawing. My typical fear plugs the crux jam with a #2 Camalot but I manage to get up somewhere between graceful and desperate - hopefully edging more to the graceful side of things. Max quickly follows, thrilled that he has managed an "actual move" in his words by employing a nice backstep through the crux. Bruce follows quickly (as he would) and quickly scrambles up to the base of Critter Crack.




We have a quick lunch as we watch some dark clouds swirl above us while the wind picks up. I shiver. Stunning for mid-July. Bruce explains the basics of jamming to Max and then heads up. One [uncharacteristic] pause at the crux and it's then Max's turn. He starts up.

"I'm going to punch Bruce in the face when I get up there" he gasps between breaths. "Just put in a jam he says. My. Ass."

Once past the requisite jamming, Max moves quickly with only one short hang at the crux. I, despite all previous evidence to the contrary, actual jam through the bottom without a problem and continue up. Probably the best jamming I've ever managed on Critter - I actually start to get what Bruce is always trying to explain.

We unrope on the summit ledge and head North. I rope up for the summit scramble and put in a few pieces for Max's benefit (who knew there was gear going up?). He quickly follows with only the slightest bit of trepidation.



I'll go ahead and say that Max was somewhat awed by the summit. While he'd become accustomed to the view to the West as we made out way up, the new 360 vista with a drop on all sides was something new. He signs the summit register and even stands on the true summit.

We stick around for a few minutes and then head back down for the Conn's West rap.

and then, there was the rappelling

Bruce ties the ropes together and slides on down to give Max a firemans just in case. I explain how rapping works, rig him with the standard BARK check, and then, with one slightly pleading look, he makes his way down. He's clearly not thrilled but we've told him few people are - it's a necessary evil.

We've already decided that we have time for another route and that heading back up Conn's West seems the easiest choice. By the time i finish rapping I find Bruce hard at work trying to free a purple Metolius fixed by some over-enthusiastic noob. After indulging him for a few minutes, I head up the chimney pitch. Max has one short fall at the beginning trying to follow the direct line and then some fun working out chimney technique.

Bruce swarms up and then heads up the corner pitch. Max has a great time on this pitch just working his way up with steady progress. I hit the belay just in time for an odd conversation with Bruce and another party trying to negotiate with us the share ropes for the rap - which we really don't need.

Max is much more comfortable on rappel this time. Two raps later and we're headed down (barely missing Danny on his way to do Back to the Front. Again). Our purpose is clear - chips and Sierra Nevada. One quick stop to see if Ben is around (complete with Bruce's clever, and remarkably legible, note to Ben using a burnt piece of firewood as writing utensil) and we're on our way home.

Sorry again Aunt Darryl - Max seemed to have a good time.

Tuesday, July 14, 2009

and...we're back

So yeah, its been a bit. Work, low motivation.

Stuff dammit. Don't question me.

So back at the whole ASP.Net MVC thing which, in the considerable interim, has made it to 1.0. Did the whole Nerd Dinner thing which I found interesting - and not just from the framework perspective. Lots of other goodies in there like IoC, mocking, testable patterns.

Anyway, back on to the redesign effort. It would be really easy, and probably considerably faster to just re-implement the app, apply my lessons learned, and be done with the whole thing. Probably be able to knock it out in a month or so. But then I don't know what I would learn and probably skip over some important things.

Like testing.

So I'm making a commitment right here that I will write the tests I didn't last time. I will take the time to have a legitimate go at TDD. I will think first before I go whipping away at new features. The whole point of this exercise is to learn right? And not just the latest hotness but about things that are generally useful no matter what.

But good lord, one 16 tests and only one controller sorta covered? It's gonna be a looong road.