Category Archives: Books

Test-Drive ASP.NET MVC Review

A few years back I started dallying with test-driven development, but I never fully committed to the practice. This wasn’t because I didn’t believe in the value of TDD; it was more a matter of not completely understanding how to incorporate “test first” into my everyday development. Back in my web forms days, I could point fingers at the framework for my ignorance and laziness. After all, web forms weren’t exactly designed for testability so who could blame me for not embracing TDD in those conditions, right? But when I switched to ASP.NET MVC and quickly found myself fresh out of excuses and it became instantly clear that it was time to get my head around red-green-refactor once and for all or I would regretfully miss out on one of the biggest selling points the new framework had to offer.

Test-Drive ASP.NET MVC

I have previously written about how I learned ASP.NET MVC. It was primarily hands on learning but I did read a couple of ASP.NET MVC books along the way. The books I read dedicated a chapter or two to TDD and they certainly addressed the benefits of TDD and how MVC was designed with testability in mind, but TDD was merely an afterthought compared to, well, teaching one how to code the model, view and controller. This approach made some sense, and I learned a bunch about MVC from those books, but when it came to TDD the books were just a teaser and an opportunity missed.  But then I got lucky – Jonathan McCracken contacted me and asked if I’d review his book, Test-Drive ASP.NET MVC, and it was just what I needed to get over the TDD hump.

As the title suggests, Test-Drive ASP.NET MVC takes a different approach to learning MVC as it focuses on testing right from the very start. McCracken wastes no time and swiftly familiarizes us with the framework by building out a trivial Quote-O-Matic application and then dedicates the better part of his book to testing first – first by explaining TDD and then coding a full-featured Getting Organized application inspired by David Allen’s popular book, Getting Things Done. If you are a learn-by-example kind of coder (like me), you will instantly appreciate and enjoy McCracken’s style – its fast-moving, pragmatic and focused on only the most relevant information required to get you going with ASP.NET MVC and TDD.

The book continues with the test-first theme but McCracken moves away from the sample application and incorporates other practical skills like persisting models with NHibernate, leveraging Inversion of Control with the IControllerFactory and building a RESTful web service. What I most appreciated about this section was McCracken’s use of and praise for open source libraries like Rhino Mocks, SQLite and StructureMap (to name just a few) and productivity tools like ReSharper, Web Platform Installer and ASP.NET SQL Server Setup Wizard.  McCracken’s emphasis on real world, pragmatic development was clearly demonstrated in every tool choice, straight-forward code block and developer tip. Whether one is already familiar with the tools/tips or not, McCracken’s thought process is easily understood and appreciated.

The final section of the book walks the reader through security and deployment – everything from error handling and logging with ELMAH, to ASP.NET Health Monitoring, to using MSBuild with automated builds, to the deployment  of ASP.NET MVC to various web environments. These chapters, like those prior, offer enough information and explanation to simply help you get the job done. 

Do I believe Test-Drive ASP.NET MVC will turn you into an expert MVC developer overnight?  Well, no.  I don’t think any book can make that claim.  If that were possible, I think book list prices would skyrocket!  That said, Test-Drive ASP.NET MVC provides a solid foundation and a unique (and dare I say necessary) approach to learning ASP.NET MVC.  Along the way McCracken shares loads of very practical software development tips and references numerous tools and libraries. The bottom line is it’s a great ASP.NET MVC primer – if you’re new to ASP.NET MVC it’s just what you need to get started. 

Do I believe Test-Drive ASP.NET MVC will give you everything you need to start employing TDD in your everyday development?  Well, I used to think that learning TDD required a lot of practice and, if you’re lucky enough, the guidance of a mentor or coach.  I used to think that one couldn’t learn TDD from a book alone. Well, I’m still no pro, but I’m testing first now and Jonathan McCracken and his book, Test-Drive ASP.NET MVC, played a big part in making this happen.  If you are an MVC developer and a TDD newb, Test-Drive ASP.NET MVC is just the book for you.

Professional ASP.NET MVC 2 Review

What’s up with Ben? All he’s been writing about lately is Ruby, Ruby, Ruby. Doesn’t he work with ASP.NET MVC anymore? Let me assure you that I do – just about every single day and it’s been for quite a while now. Sure, I have been spending time learning Ruby but I’m also constantly developing my primary craft, ASP.NET MVC with C#. So, inspired by yesterday’s virtual MvcConf, I’m going to get back to what I do every day and share a bit about learning ASP.NET MVC with you.

Professional ASP.NET MVC 2 by Scott Hanselman: Book CoverI have told this story before but early in my career, when I wanted to learn a new technology, I’d sit on the floor in the bookstore aisle and work my way through each of the available books on a given subject.  Put in enough time in a bookstore and you can learn just about anything. I used to really enjoy this time but over the years my habits have certainly changed.  Whereas books used to be the only place I could find solutions to my problems, now they may be the very last place I look. Case in point, it wasn’t until I had worked with the ASP.NET MVC 1.0 Framework for more than a year, and I had a few projects and a couple of major deployments under my belt, did I finally read through Steven Sanderson’s Pro ASP.NET MVC Framework. With so many resources at my fingertips (podcasts, screen casts, blogs, stackoverflow, open source projects, I was able to get up to speed with ASP.NET MVC without reading a single book.  So, I didn’t until late into the game.  

This past April, the day after the RTM release became available, I upgraded my primary MVC project to MVC 2.  Now, a few months later, there are a handful of MVC 2 books on the shelves of those said bookstores and I now offer you a review of Professional ASP.NET MVC 2.  You may know that I have given a lot of praise to Sanderson’s first book so why did I choose Professional ASP.NET MVC 2 over the second edition of Sanderson’s book? Well, the NerdDinner chapter (a.k.a the free bits) of Professional ASP.NET MVC 1.0 offered me a really great MVC primer but I never got around to buying the book.  Not only has the guilt weighed on me a bit, it’s also been quite the cliffhanger.  Having now read through the second edition of Professional ASP.NET MVC 2, I now know that everything worked out for Guthrie, Hanselman, Haack, Conery but I’ve been worried.  (Sorry if I just spoiled the ending for you.)  Anything else?  Yes. Full disclosure, a copy of Professional ASP.NET MVC 2 kind of fell in my lap as Jon gave me a copy on my birthday. He didn’t know it was my big day but it was.  And this leads us into the first thing you’ll undoubtedly notice about the book – there is one more author, Jon Galloway, and the four foreheads on the book cover have been replaced by a blurry bobsled.  Welcome change all around, I think.

As you may have guessed, Professional ASP.NET MVC 2 begins with a new and improved NerdDinner walkthrough. With the book’s first release, I coded up the application from scratch as I followed along, step by step, with the tutorial. I even uncovered and fixed a couple of bugs, but don’t tell.  This new NerdDinner tutorial does a fine job of working in a number features which were introduced with MVC 2.  That’s stuff like HTML Encoding Code Blocks, Strongly Typed HTML Helpers, Templated Helpers, and Client-Side Validation.  There are other new features, and we’ll get to those. If you can get through the tutorial and understand what MVC has to offer, congratulations, you now know enough to be dangerous. But should you stop there? Does the NerdDinner sample application provide you everything you need to become a full-fledged MVC developer?  You might think so, but nope, not even close.  Thus, there’s a lot more book to give you the rest of the scoop.  Think of the NerdDinner sample as the appetizer which whets your appetite, leaving you craving for the main course.  Sorry, I couldn’t help myself…

With that, onto the rest of the book review:

Chapter 2 shares the history of the MVC design pattern and runs through other popular MVC web frameworks you may have seen running in the wild. This chapter also brings attention to the “how” and “why” ASP.NET MVC came into existence. Chapter 3 builds on these same points and explores ASP.NET MVC basics like separation of concerns, maintainability and testability and how ASP.NET MVC relates to both WebForms and ASP.NET as a whole.  You might be thinking, “That’s great but is this going to make me a better MVC developer?”  I was tempted to say that these two chapters aren’t required reading unless you are a complete MVC newbie, but the truth is there’s always value in learning about the background of a technology, pattern, language or framework in order to better understand and master it.  And knowing this information will separate those passionate about MVC from those who merely code against MVC.  So, yes, these chapters will make you a better developer.

Chapter 4 digs into routing and sheds light on a number of sophisticated scenarios. If you have a good handle on routing from your work with MVC 1, you will acknowledge the chapter as being well-written but nothing new is going to jump off the page at you.  However, if you are new to  MVC, you need a strong understanding of outgoing and incoming routes, route patterns and how possible gotchas like Overflow Parameters work and this book does a wonderful job explaining these concepts.  And don’t forget that routing is now exposed in the ASP.NET libraries to be used in WebForms too.  You know, just in case MVC isn’t your cup of tea.

Chapter 5 and 6 dive into controllers and views, respectively.  If you’re new to MVC, the authors walk you through everything you’ll need to know about the C and V in MVC.  For those focusing on the MVC 2 bits, there’s a very nice overview of how requests are handled on the server along with an explanation of how to benefit from the new Asynchronous Controller Actions.  You may have picked up a lot about what views have to offer from the NerdDinner tutorial already but you’d be surprised what else you’ll pick up from this detailed chapter.  Again, for those honing in on MVC 2, give special attention to the new Html.Action and Html.RenderAction helper methods.  Final note on views – I commend the authors for including a rundown of the most popular alternative view engines.  Pretty classy.  On aside, since we’re talking about the V and the C, there isn’t a chapter dedicated to the M, models.  The NerdDinner walkthrough may have sufficiently covered this topic, but the topic was otherwise absent.

Chapter 7 is focused on Ajax, partials and jQuery.  This section is somewhat like a cookbook with lots of recipes.  It’s a little different than the rest of the book as it offers more code examples than written explanation of what the AJAX and jQuery libraries bring to the MVC 2 table. Having worked with MVC for a while now, it’s apparent from Day 1 of development that one needs to have their Ajax and Javascript/jQuery hat on if they want to work with effectively with the framework.  Thankfully Chapter 7 offers a surfeit of practical examples.  Be sure to bookmark this section because you’ll be referring back to it when you need a ratings or autocomplete textbox implementation.

Chapter 8 shows us how one can use Filters to add behavior to action methods.  For the MVC neophytes, filters are powerful.  Soak this chapter in.  For the MVC veterans, be on the look out for the RequireHttps action filter which was introduced with MVC 2. 

Chapter 9 speaks to securing our MVC applications.  I agree with the authors – this should be required reading.  This chapter uses case studies, quotes, short stories, humor, scare tactics, anything and everything to get important points across to the reader.  Listen, security is important.  If you’re a WebForms convert, read carefully as MVC doesn’t hold your hand quite as much as the WebForms world does when it comes to securing your application.  And give thanks to the authors for their willingness to talk about security concerns throughout the book as well dedicate an entire chapter to this topic.  This chapter also includes number of additional reading references which might be worth your time.

Chapter 10 and 11 are dedicated to TDD, unit testing and testable design patterns. The book provides a nice introduction into these topics and solid foundation on how to get started with these design/testing techniques.  Professional ASP.NET MVC 2 includes more than 50 pages of TDD/testing instruction.  Truly, one of the greatest benefits of ASP.NET MVC is testability and if you are new to testing, this book will be a wonderful jumping off point for you.

I’m a bad person. I didn’t read Chapter 12, Best of Both Worlds: Web Forms and MVC Together. I skimmed through it but that’s it.  Obviously there’s demand for this information or it wouldn’t be included in the book but mixing WebForms and MVC doesn’t pertain to me right now. Maybe I’m being shortsighted but I’d like to keep these worlds separate for now. If there comes a time and I need to migrate a WebForms app to MVC, I’ll be sure to come back to this chapter.  For now, it remains unread. Sorry.

Remember how the NerdDinner tutorial sample showed off a number of the new ASP.NET MVC 2 features?  Well, it didn’t catch them all.  That’s where Chapter 13 comes in – offering a roll up of everything new to MVC.  You may actually want to read this chapter first just to become acquainted with the new bits.  That way you can be sure to pick up on the callouts elsewhere in the book.  A couple of important notes – you will find details about Areas in Chapter 13 which you won’t find in any other section. Also there’s an important note about breaking changes with JsonResult when upgrading from MVC 1 to 2.  The change is web vulnerability related and don’t say I didn’t warn you.

A few additional notes about the book which I couldn’t find a good place for elsewhere:

  • Comments from the ASP.NET Product Team are inserted throughout the book. These tips and additional info were my favorite part of the book.  It’s kind of like VH1’s “Behind the Music” to me
  • My only real concern with the NerdDinner tutorial is the emphasis placed on the Entity Framework (EF).  When the original tutorial was published, I encouraged everyone on my team to work through the sample application before diving into their first MVC project.  One of my colleagues was so impressed with MVC that they presented what they learned to the rest of the team.  Guess the name of the presentation. It was “An Overview of the .NET MVC Entity Framework.”  Yikes! In the individual’s defense, they had no prior experience with the .NET stack and frankly the Professional ASP.NET MVC book does drive home the concept of building out one’s model with EF.  There is quick mention of other ORMs which can be used with ASP.NET MVC, but guess which path someone new to .NET will follow?  I don’t feel the use of the Entity Framework is inappropriate in the NerdDinner sample, but I do think it is important to stress (yes, a little more) that EF is not part of the MVC framework and maybe even offer hints as to how one might hook in another ORM if they so choose. This said, I suppose I have the same issue with the references to ASP.NET Forms Authentication, ASP.NET Membership and Role Management APIs, not to mention the Visual Studio Unit Test framework.  [Disclaimer: I am using EF4 and the ASP.NET Membership stuff on my primary project and I think they are both the bees knees.]
  • If you are turning to MVC in hopes to never hear or read about WebForms again, you’re kind of out of luck because Professional ASP.NET MVC offers lots of WebForms commentary.  If you are only interested in MVC, this constant reminder of  WebForms might be a little distracting.
  • In the NerdDinner sample, data-type validation was implemented using DataAnnotations.  DataAnnotations are fine, but I would have liked to read more about validating true business rules (e.g. ensuring passwords are strong, validating a shipping date doesn’t fall on a weekend or holiday, or guaranteeing a submitted email address is unique). Managing this type of validation can be complicated and this topic was glossed over entirely.
  • Your Professional ASP.NET MVC 2 purchase comes with two weeks of TekPub access. You may wish to factor this in when your calculating the true purchase price.

As I alluded to earlier, you may be tempted to read through the NerdDinner tutorial and then go off and code up a storm. Don’t do it! The rest of the book has so much to offer – especially to someone brand new to ASP.NET MVC.  Really, soak up what’s provided in all of the chapters.  And as I climb onto my soapbox, please remember that sample applications like NerdDinner demonstrate basic and generalized implementations in order to highlight new features and ensure focus is firmly set on teaching and learning specific information.  If you wish to really understand ASP.NET MVC 2 development, work through the NerdDinner tutorial, read Professional ASP.NET MVC 2 cover to cover, write lots of your own code, read lots of other people’s code, come up with your own ideas and keep learning from the many other resources which are readily available to you.  I recommend Professional ASP.NET MVC 2 – it’ll get you off to a great start.

Pro ASP.NET MVC Framework Review

Early in my career, when I wanted to learn a new technology, I’d sit in the bookstore aisle and I’d work my way through each of the available books on the given subject.  Put in enough time in a bookstore and you can learn just about anything. I used to really enjoy my time in the bookstore – but times have certainly imagechanged.  Whereas books used to be the only place I could find solutions to my problems, now they may be the very last place I look. 

I have been working with the ASP.NET MVC Framework for more than a year.  I have a few projects and a couple of major deployments under my belt and I was able to get up to speed with the framework without reading a single book*.  With so many resources at our fingertips (podcasts, screencasts, blogs, stackoverflow, open source projects,, you name it) why bother with a book?

Well, I flipped through Steven Sanderson’s Pro ASP.NET MVC Framework a few months ago. And since it is prominently displayed in my co-worker’s office, I tend to pick it up as a reference from time to time.  Last week, I’m not sure why, I decided to read it cover to cover.  Man, did I eat this book up.  Granted, a lot of what I read was review, but it was only review because I had already learned lessons by piecing the puzzle together for myself via various sources.

If I were starting with ASP.NET MVC (or ASP.NET Web Deployment in general) today, the first thing I would do is buy Steven Sanderson’s Pro ASP.NET MVC Framework and read it cover to cover.

Steven Sanderson did such a great job with this book! As much as I appreciated the in-depth model, view, and controller talk, I was completely impressed with all the extra bits which were included.  There a was nice overview of BDD, view engine comparisons, a chapter dedicated to security and vulnerabilities, IoC, TDD and Mocking (of course), IIS deployment options and a nice overview of what the .NET platform and C# offers.  Heck, Sanderson even include bits about webforms!

The book is fantastic and I highly recommend it – even if you think you’ve already got your head around ASP.NET MVC.  By the way, procrastinators may be in luck.  ASP.NET MVC V2 Framework can be pre-ordered.  You might want to jump right into the second edition and find out what Sanderson has to say about MVC 2.

* Actually, I did read through the free bits of Professional ASP.NET MVC 1.0.  But it was just a chapter – albeit a really long chapter.

Why’s (Poignant) Guide to Ruby

You’re familiar with O’Reilly’s brilliant Head First Series, right?  Great.  Then you know how every book begins Book cover of Head First Design Patternswith an explanation of the Head First teaching style and you know the teaching format which Kathy Sierra and Bert Bates developed is based on research in cognitive science, neurobiology and educational psychology and it’s all about making learning visual and conversational and attractive and emotional and it’s highly effective.  Anyway, it’s a great series and you should read every last one of the books. Moving on…

I’ve been wanting to learn more about Ruby and Why’s (Poignant) Guide to Ruby has been on my reading list for a while and there was talk about cartoon foxes and other silliness and I figured Why’s (Poignant) Guide to Ruby probably takes the same imageunorthodox teaching style as the Head First books – and that’s great – so I read the book, in piecemeal, over the last couple of weeks and, well, I figured wrong.

Now having read the book, here’s my take on Why’s (Poignant) Guide – it’s very creative and clever and it does a darn good job of introducing one to Ruby.  If you’re interested in Ruby or simply interested, the online book is worth your time.  If you’re thinking (like me) that cartoon foxes will be doing the teaching, that’s simple not the case.  However, the cartoons and the random stories in the sidebar may serve a purpose. Unlike the Head First books where images and captions are used to further explain the teachings, the cartoons and stories in Why’s Guide serve as intermission and offer your brain a brief moment of rest before the next Ruby concept is explained.  It’s not a bad strategy, but definitely not as effective as the Head First techniques.


ASP.NET MVC HandleError Attribute

Last Wednesday, I took a whopping 15 minutes out of my day and added ELMAH (Error Logging Modules and Handlers) to my ASP.NET MVC application.  If you haven’t heard the news (I hadn’t until recently), ELMAH does a killer job of logging and reporting nearly all unhandled exceptions.  As for handled exceptions, I’ve been using NLog but since I was already playing with the ELMAH bits I thought I’d see if I couldn’t replace it.

Atif Aziz provided a quick solution in his answer to a Stack Overflow question.  I’ll let you consult his answer to see how one can subclass the HandleErrorAttribute and override the OnException method in order to get the bits working.  I pretty much took rolled the recommended logic into my application and it worked like a charm. 

Along the way, I did uncover a few HandleError fact to which I wasn’t already privy.  Most of my learning came from Steven Sanderson’s book, Pro ASP.NET MVC Framework.  I’ve flipped through a bunch of the book and spent time on specific sections.  It’s a really good read if you’re looking to pick up an ASP.NET MVC reference.

Anyway, my notes are found a comments in the following code snippet.  I hope my notes clarify a few things for you too.

  1. public class LogAndHandleErrorAttribute : HandleErrorAttribute
  2. {
  3.     public override void OnException(ExceptionContext context)
  4.     {
  5.         // A word from our sponsors:
  6.         //
  7.         //      and Pro ASP.NET MVC Framework by Steven Sanderson
  8.         //
  9.         // Invoke the base implementation first. This should mark context.ExceptionHandled = true
  10.         // which stops ASP.NET from producing a "yellow screen of death." This also sets the
  11.         // Http StatusCode to 500 (internal server error.)
  12.         //
  13.         // Assuming Custom Errors aren't off, the base implementation will trigger the application
  14.         // to ultimately render the "Error" view from one of the following locations:
  15.         //
  16.         //      1. ~/Views/Controller/Error.aspx
  17.         //      2. ~/Views/Controller/Error.ascx
  18.         //      3. ~/Views/Shared/Error.aspx
  19.         //      4. ~/Views/Shared/Error.ascx
  20.         //
  21.         // "Error" is the default view, however, a specific view may be provided as an Attribute property.
  22.         // A notable point is the Custom Errors defaultRedirect is not considered in the redirection plan.
  23.         base.OnException(context);
  25.         var e = context.Exception;
  27.         // If the exception is unhandled, simply return and let Elmah handle the unhandled exception.
  28.         // Otherwise, try to use error signaling which involves the fully configured pipeline like logging,
  29.         // mailing, filtering and what have you). Failing that, see if the error should be filtered.
  30.         // If not, the error simply logged the exception.
  31.         if (!context.ExceptionHandled   
  32.             || RaiseErrorSignal(e)      
  33.             || IsFiltered(context))     
  34.             return;
  36.         LogException(e); // FYI. Simple Elmah logging doesn't handle mail notifications.
  37.     }

15 Random Things I’ve Learned from Jeffrey Richter

I read through Jeffrey Richter’s CLR via C# not too long ago.  This evening I cracked it open again and jotted down a few notes on what I personally took away from the book. Of course, if I spent the time to write down everything I learned, I might still be busy writing.  I’ve thrown in the towel and though I’m probably not doing the book justice, here are 15 random things I have learned from Jeffrey Richter:CLR Via C# by Richter Richter: Book Cover

Page 3 – Way more than I ever wanted to know about the CLR’s execution model.  That is, everything about Managed Modules, Assemblies, Intermediate Language (IL), Framework Class Library (FCL), Common Type System (CTS) and Common Language Specification (CLS.) 

Page 56 – How to properly version your assemblies – including a breakdown of the assembly version resource information, how/when to increment the major, minor, build and revision numbers, and the distinction between AssemblyFileVersion, AssemblyInfomationVersion and AssemblyVersion numbers.

Page 144 – Best practices on how to write code to compare objects.  Here, Richter drills into object equality, identity and hash codes.

Page 177 – How the compiler handles constants – their values are embedded inside the IL code at compile time. 

Page 185 – Why one must beware of code explosion with initializing fields within classes with multiple constructors.  Key points: Any fields that the constructor doesn’t explicitly overwrite are guaranteed to have a value of 0 or null.  The compiler embeds, at the beginning of all constructor methods, field initialization code.  You should consider not initializing the default field value at the point of field declaration and instead perform the common initialization in a single constructor and have all other constructors explicitly call the common initialization constructor before overriding varying defaults. 

internal sealed class SomeType
    // Do not explicitly initialize the fields here
    private Int32 x;
    private String y;
    private Double z;

    // Sets all fields to their default
    // All constructors explicitly invoke this constructor
    public SomeType()
        x = 5;
        y = "Ben";
        z = 3.14159;

    // Sets all fields to their default, then changes x
    public SomeType(Int32 x) : this()
        this.x = x;        

    // Sets all fields to their default, then changes y
    public SomeType(String y) : this()
        this.y = y;

    // Sets all fields to their default, then changes x, y
    public SomeType(Int32 x, String y) : this()
        this.x = x;
        this.y = y;

Page 254 – The power of string interning and string  pooling.

Page 309 – How to perform unsafe array access and fixed-sized arrays.

Page 322 – How to implement multiple interfaces that have the same method name and signature and…

Page 325 – Why you need to be really careful when using explicit interface method implementations.

Page 365 – A quick introduction into Wintellect’s Power Collections library which extends the .NET Framework’s Class Library with an assortment of collection classes. The Power Collections library, documentation, and licensing information is available on CodePlex.

Page 411 – How the CLR provides special support for Nullable value types.

Page 431 – A little background on System.Exception, System.SystemException and System.ApplicationException and how Microsoft through the basic principles out the window.

Page 457 – Way more information than any single person should know about Garbage Collection (GC).

Page 562 – How to build a system which support add-ins.

Though it wasn’t mentioned in the book, Richter’s Power Threading library (DLL) contains many classes to help with threading and asynchronous programming for the .NET Framework, Silverlight, and the .NET Compact Framework. Jeffrey has described many of the classes contained in the library by way of his MSDN Magazine Concurrent Affairs columns and I found his Channel 9 overview on the AsyncEnumerator class (which uses Yield to simplify multithreading) absolutely fascinating.  The Power Threading Library is available for download here.

That’s fifteen.  I should probably drill into a couple of these with code samples…or you could just get a copy of the book. 🙂

Random closing thought: When I was flipping through the book today I found a spider smashed between pages 72 and 73.  Ironic?

Required Reading for JavaScript Devs

I read a bit of “jQuery in Action” a couple of weeks back.  Actually all I read was the appendix which is aptly titled “JavaScript that you nejQuery in Actioned to know but might not!”  This short chapter very concisely covers JavaScript concepts which should be required learning for all web developers

If you are an experienced JavaScript developer (i.e. your JS code does more than trigger alerts, toggle divs and set window locations), you know the language is not particularly easy to get your head around.  In my opinion, most web developers have a poor understanding of JavaScript to the extent that the bulk of their JS code (mine included) is a mere collection of hacked-together, simple statements.  Based on my judgement, the appendix title should read “JavaScript that you need to know but you more than likely do not!” 

Generously, “jQuery in Action” provides a thorough overview of “basic” JS concepts like objects and JSON, functions being first-class objects, controlling what “this” means along with closures.  I’ve really enjoyed jQuery in Action thus far – particularly because the authors ensure that their readers have a firm understanding of core JavaScript concepts which are arguably the necessary foundation to effectively use jQuery.

The next time you find yourself in your local bookstore, sit down in the aisle with a copy of “jQuery in Action” and give the appendix a good read.  It’s 19 pages of pure Javascript goodness.  And who knows?  You might even purchased the copy and read the jQuery parts…


Learning Test Driven Development

I am relatively new to the Test Driven Development (TDD) scene.  Though I have read up on the subject (specifically Test Driven: TDD and Acceptance TDD for Java Developers by Lasse Koskela), my only hands-on experience is limited to a single, 3-month project where I was the lone developer.  All other information gathered on the subject has been through blog entries, podcasts, ramblings and the occasional deCover Imagemo in the office.  Though I believe I have a good understanding of TDD methodologies, I am far from putting this, dare I say, knowledge to practice.  Good practice, that is…

A spike is a term associated with TDD.  A spike is nothing more than quick coding exercise which validates or invalidates an assumption.  Lasse Koskela says it more eloquently:

A spike is a short experiment with the purpose of familiarizing ourselves with the technology, tools, algorithms, and so forth, that we need for solving the problem at hand.  A spike is  a way to make an unknown known — at least to a point where we know whether it’s worth continuing to dig that way or whether we should start looking for another way.

If you are familiar with TDD concepts, you know that spikes offer no value with it comes to testability, maintainability, etc.  They are merely quick prototypes which I find immensely helpful but should not be considered the focal point of TDD.  Well, my first crack at TDD resulted in roughly 70% spikes and 30% actual tests.  Not too good.

There is no doubt in my mind that I always had the best intension to test-code-refactor, but I wasn’t yet familiar enough with TDD to know I was way off course. There was also no one around to put me on the right track (or keep me honest.) Putting my ego aside, I know I could have used some hand-holding when I was starting off with TDD.

Test Driven Development is a discipline.  Like many other disciplines, TDD requires a teacher, student and practice.  The teacher offers instruction and ensures the discipline is practiced correctly.  The good student gathers knowledge and implements under watchful guidance.  In my opinion, TDD is therefore a seemingly good fit for a team which embraces an Agile approach, collaboration, rapid development and testability.   I’m not saying the lone developer with no prior experience with TDD is not capable of learning TDD on their own. I know some are.  I know guys who have done it.  Simply, I am stating that TDD seems most accessible to the mentored developer working with team members who previously adopted the methodology.  To put it another way, I bet Test Driven Development concepts are best learned through practical, hands-on example.

I haven’t given up on TDD yet.  Who wants to hold my hand?