“Right”

Disclaimer: Since I started the draft of this post (July 14th) I’ve came across several people who managed to convey what I was thinking far more eloquently that I ever could. I debated not finishing the post but realised that was succumbing to the very feeling I was trying to express, that it wasn’t “good” enough. So go read John Sonmez post on When Being good is Bad and Iris Classon‘s posts “My First year of Programming“, 365 Stupid Questions” series and her Hanselminutes interview then indulge me as I dump my thought loosely below in my first steps to becoming a better blogger…

“Am I doing this ‘right'”

Since committing to .net a few years ago from Classic asp I’ve increasingly found myself suffering from a mental anguish, an almost irrational fear on whether my code was “right”. It was as if solving the problem was no longer enough, it had to be done “right”. “Right” however proved to be something that always remained just outwith my grasp.

I switched from Classic asp to c# and mvc. Great they said, but you should also use an ORM.

So I write some more code and implement linq2sql. Fantastic they say, but it’s outdated, use entity framework.

I rebel. I Install-Package dapper. Fine they say. But you really should be using TDD. And your code isn’t really DRY. And your not following SOLID principles.

WTF

I get depressed. I yearn for the simple days where I wrote simple code that Got Stuff Done. When I wasn’t judged. My head tells me that “this is better, this is ‘right'” but my in my heart I don’t feel it. My focus is constantly on the fine detail of the implementation, not on the problem I’m trying to solve. I abandon ideas without even writing any real code because I can’t fit my approach into a mythical model of perfection. I no longer care if I’m solving business needs but instead obsess over what other may think of my code. I become locked in a crippling cycle of Analysis Paralysis.

I despair. This used to be fun.

I consider giving up.

Sadly due to Financial but mainly Marital constraints my dreams of being of joining the circus are cut short and I focus back on what it is I’m missing.

Meet the New Boss, Worse than the old boss

In my earlier days, I was a self-taught Classic ASP programmer. I tried things, copied, pasted and response.write’d my way through several projects, from 3-pages-for-£500 starter sites for local businesses to a knowledge management system that was ultimately rolled out across all Business Gateway offices in Scotland. My focus was always on what the customer wanted. I was the sole developer, architect and often trainer in the systems I built. I took pride in them, followed ‘best practices’ as far as my application design went but ultimately I reveled in the freedom afforded to me by the liberal and seductive ways of Classic ASP.

As time progressed I began to hit the inherent limits of classic ASP. The natural progression was onto .NET and once the MVC framework was released (I’m not a webforms fan) I finally committed both myself and the development team I was leading onto MVC 1.0 and away from Classic ASP.

We turned out our first big project despite not really knowing what we were doing and it performed well under peak traffic for our business. It was, by all accounts, a success and a great achievement for the team who built it in a ridiculously short timescale, but for me both personally and professionally it felt overly complex and cumbersome. Ultimately we’d made the switch to .NET but I couldn’t really see what we’d gained.

MVC, TDD, DRY, GSOH, WLTM, FML…

We had all the component parts of a good project. According to the book we had done it “right”. But I was increasingly becoming frustrated by my attempts to constrain the project to these ideals. I found myself refusing to make changes to the project that we would otherwise have accommodated on the old site. Adding new sections or modifying existing behavior became major undertakings (I work in a very reactive industry, completely changing the behavior of one page several times a day is not uncommon). Basically, our old spaghetti code ASP site was far easier to hack on a daily basis.

As a developer this was quite difficult to take. I’d taken this route as progress and it had completely failed. Sure, the app well worked but it was a maintenance nightmare. I’d became more hung up on whether my linq2sql implementation was a true repository, or on created a ‘service’ layer that was basically just a pass-through of the repo that I’d completely lost my sense of direction. On paper it was perfect. In reality is was a miracle it built when you hit F5.

How could this be..

The short version, I f*cked it up. The not much longer version, Ideals are just that, aspire to them by all means but don’t let them rule your life. I attributed the failure of the project to my own perceived lack of ability rather than the real scenario which was that we’d failed to plan for our uber-reactive change needs in the design.

Retrospective

The project mentioned above was almost 3 years ago. I’ve built countless MVC apps since, each slightly better than the last. I’ve gradually started to introduce some design methodologies into my projects (repository/activerecord data access, sensible separation of projects) but don’t let them rule my initial approach. I still aspire to my previous ideals but I’ve also accepted that my opinion counts as well. Do what works for you. Read and research everything, experiment with new approaches but ultimately make your own decision.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: