Some HDR shots

I’ve gotten a digital camera for my birthday from the wife – nothing too fancy, a Canon XS with the EFS 18-55 IS kit lens. I’ve been putting it through its paces lately, getting some practice with a variety of shots. A few weeks ago, I’ve found some pretty interesting shots on Flickr and it turns out it was Trey Ratcliff’s work. Needless to say I find his stuff pretty awesome. He’s got an HDR tutorial that inspired me quite a bit, and after a few unsuccessful HDR attempts I came up with a pretty decent shot.

This was taken around 8:15 PM at the Anderson train station in Calgary. Three exposures, +/-2 EV, from the tripod, with the kit lens. It’s the best one yet, although it has some ghosting and noise issues. I don’t really have a good noise reduction software.

Here’s another one, from our living room. Three exposures, +/-2 EV apart, with the tripod and the EF 50 1.8 II. Pretty mundane subject, I’m trying to get the creative juices flowing and learn more about light.

By the way, the EF 50 is absolutely amazing, scored it for 120 at Future Shop of all places and it’s worth every penny. It’s giving me some grief with the slow/noisy focus. The DOP is also very shallow, which makes certain shots tricky until you get used to it.

_MG_2066_7_8_MG_2494_5_6


jQuery web service proxy

A little while back I was looking for a nice convenient way of calling ASP .Net web services from JavaScript. I looked at the MS Ajax implementation, however I’m a little uncomfortable with the Script Manager and all the related plumbing. It’s just a little heavy for my taste, and I’m not a big fan of the auto generated web service proxy. I also wanted to keep the door open for porting my project to Mono and I wasn’t sure if those features have been ported yet (if they have, ping me). I looked at jQuery, Prototype and Scriptaculous and of those three I liked jQuery the best for the additional features the package offers. Right off the bat jQuery was pretty simple to use and set up, but a little too much typing for my taste. Here’s what I came up with:

   1:  (function($) { $.proxy = function(options) {
   2:          
   3:          /* Default .Net web service proxy options. */
   4:          var defaults = {
   5:              mode: "POST",
   6:              contentType: "application/json;charset=utf-8",
   7:              dataType: "json",
   8:              endPoint: "",
   9:              data: "",
  10:              success: {},
  11:              failure: {}
  12:          };
  13:          
  14:          /* Extend (or override) the defaults with any passed in options. I really like this extend feature. */
  15:          var options = $.extend(defaults, options);
  16:   
  17:          /* Make the ajax call using $.ajax() */
  18:          return $.ajax({
  19:              url: options.endPoint,
  20:              type: options.mode,
  21:              contentType: options.contentType,
  22:              dataType: options.dataType,
  23:              data: options.data,
  24:              success: options.success,
  25:              error: options.failure
  26:          });
  27:      };
  28:  })(jQuery);

This is a simple jQuery plug-in that encapsulate the details of calling ASP .Net web services. This is pretty sweet since now I can do something like this and avoid all that set-up work every time I need to call into the back-end:

   1:  Zanzibar = {}
   2:  Zanzibar.Web = {
   3:      LocationService: {
   4:          Get: function(options) {
   5:              $.extend(options, { endPoint: "http://localhost:60088/RPC/GeoLocation.asmx/Get" });
   6:              
   7:              return $.proxy(options);
   8:          }
   9:      }
  10:  }

This becomes my proxy now. I’m extending the options with the specific end point for the web method I need to call and the usage pattern for this becomes something like the following:

   1:  Zanzibar.Web.LocationService.Get({
   2:      data: "{ userId: 10001 }",
   3:      success: successCallback,
   4:      failure: errorCallback
   5:  });

This is great, because now all I need to worry about is the actual parameters I want to call my web service with, none of the setup work is needed up front anymore. Clearly other methods can be added and you can provide a really nice, rich wrapper for a web service this way. No complex inheritance, just some simple composition and extension of passed in parameters with some default settings. I really like the $.extend() function, comes in very handy for defaulting parameters and helping cut down on verbosity somewhat. Using that cool feature I can trim the code down but I still retain the power of customizing every aspect of my web service call if I need to.

Sustainable development

Why is it that many development shops still do not practice agile? What makes adoption so slow even today after so many successful projects? There are countless evangelists out there preaching and demonstrating the practices yet it seems that the old ways of waterfall like development are anything but numbered. Even worse, there are plenty of shops out there that claim to practice agile, and ignore some of the most basic principles – first one that comes to mind is continuous improvement. Ever dodging that post mortem, perpetually avoiding those tough questions – are we delivering value to our customers? Is our software maintainable, flexible, can it respond to the clients rapidly changing needs, particularly in this difficult economic climate?

A small startup will wither and die if they’d be providing these subpar services to their customers. Some large corporations, unfortunately, seem to benefit from inertia and continue to do business as usual. Are their customers not demanding enough? Do they continue supporting them in hope that one day they will get what they pay for? It can’t be the customers, after all our services haven’t been an astounding commercial success.

I’m not even sure where this was going. Suffice to say I’m a string believer in sustainable development.


TDD and I

This is a re-take of one of my posts to the ALT.Net Google group. Probably a little of topic so I just want to capture it here, for future reference.

I'd like to throw in my two cents. I'm a TDD noob, so it might be relevant in this context. The point of the lengthy story that follows is that you can only lead a horse to water, as one of my colleagues likes to say when we discuss taking over the office with TDD. If one is not open to exploring new ways of doing things and discounts it right off the bat, no progress will be made. You can cite all the papers in the world, studies and research and successful projects, give examples, they will all be attributed to flukes, better funding, better building, better chairs, etc. People naturally resist change, and it will be rationalized in new and interesting ways all the time. I think the gap is not something the ALT.NET community can bridge. Each developer must try it first hand to experience the benefits. And try hard, because it’s not easy. For me the TDD showdown happened privately, I was both the TDD-er and the non-TDD-er.

That being said, big thanks go out to the folks on this board, and others, who’ve paved the way for me to become a better developer. I don’t think we’d be where we are now if it weren’t for huge contributions from guys like you. And for what it’s worth, I think the ALT.NET movement is doing a great job of moving forward the .Net world, and promoting continuous improvement. Read no further unless you have time for a rant.

I've been trying to promote TDD at work for the past few months. I've spent a lot of my personal time actually doing it to get hands on experience, scoping out different open source projects to get a feel for it (good vs bad unit tests, mocking, etc.) Here's one of the things that struck me in the learning process. I've been reading a lot - generally I agree with the literature on the benefits of TDD, but I was somewhat skeptical about the practical aspects - and accumulating a lot of theoretical knowledge. Still, when time came to write my first test I felt none the wiser. Complete writer's block – huh, where do I start kind of thing? So I've stumbled and tried and Googled and things started working together. I was pretty happy with the way things were going. Then I ran into things that needed testing that were doing a bunch of file manipulations. Uh oh, very unpleasant, no interface in sight in the System.IO namespace so no mocking. Gave up on TDD. Time passed, and I got uncomfortable with the lack of feedback. Yes, that is when I realized first hand that TDD was giving me something other than a bunch of asserts I could run and tell that everything was ok. Started TDD again, wrote wrappers for the System.IO part and wrote some integration tests on top of the unit tests to verify the files are handled correctly (I’m still not sure if this was the way to go, but it works pretty well in practice) and I was happy again.

A big moment for me was when I tried writing a validation framework. So I started with a little sketch of what I was trying to build. It had things like IRuleSet, IRule,IRuleResult and various implementations of those. Then I started coding, and wrote everything test first to see where it will lead. Well most of those things became superfluous. The problem I was trying to solve was much simpler – basically write a bunch of rules I could evaluate in a batch and tell a remote client everything that was wrong with their request in one remote call. Ultimately I just kept the IRuleSet<T> and expressed the rules as simple lambda’s that would return true or false. So I can do things like this:

   1: IRuleSet<string> rules = new RuleSet<string>();
   2: rules.Add(x => x.Length > 5, “Length must be greater than 5”)
   3:     .Add(x => x.Length < 10, “Length must be less than 10”)
   4:     .Add(x => x.Contains("TDD"), "Must contain TDD")
   5: List<string> brokenRules = rules.RulesBrokenBy (“TDD Rocks!”);

I liked this better than the objects soup I initially cooked up, and it works very well with some caveats. I’m sure that this would have taken a lot longer to achieve without the TDD approach, as it made me realize what my real requirements were, and that I didn’t need all that complexity I was imagining in the beginning.

Lots more tests have been written since and lots more code. The overall quality has improved and getting better every day. It is however a process of continuous improvement and it takes work. It would be hard now to turn back and do thing the old fashion way. The one thing I could have used is a good mentor to provide some guidance. Failing that, I turned to ALT.NET and the huge contributions made by the members, and it’s helped in more ways than I can describe. Thanks again to everyone that uses their free time to contribute and guide other devs! Kudos! Sorry for the rant, and slightly off topic post.


Changed theme

I was looking for a cool blog theme and I found a couple I liked. They make code look pretty crappy though, particularly longer lines in .config files and the like.I’ve decided that I’ll go back to Cogitation. Looks decent, and is very practical for showing code.


Search

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010