jordan.terrell
Just trying to make sense of things...

Type Mocking Dangerous in Static Languages

Monday, 27 August 2007 22:36 by jordan.terrell

Both Ian Cooper and Scott Bellware wrote excellent posts comparing dynamic and static languages, and how type mocking is dangerous when your using a static language (e.g. C#, VB.NET).  Scott said: "Type mocking might save your bacon when you have made poor design decisions along the way..."  I couldn't agree more!  Ian also talked about how dynamic languages leverage Duck Typing to overcome this danger.

Take a look at my friend's Duck Typing library - it's made to be used within a static language.  It too can "save your bacon" when you need to isolate legacy, tightly coupled code that you need to change and test.

Dependency Inversion vs Type Mocking: Debate

Monday, 20 August 2007 13:08 by jordan.terrell

In case you haven't noticed, there is a bit of a debate going on over Dependency Inversion and Type Mocking, and the merits of each approach.  Many bloggers have started to weigh in on it; so I thought I would join the fun.

I favor Dependency Inversion. This is not to say that both approaches don't have benefits - they clearly do, and neither side has produced completely ideal results, as was well stated by Aaron here:"...neither sides of the camp is producing Silver Bullets."

Jacob Proffitt (the originator of this discussion) has repeatedly sung TypeMock's praises - and rightly so, as it is a very powerful mocking tool. The fundamental problem I have is this: I refuse to allow my overall application design to be coupled to the availability of a commercial tool or product.  My main goal, and hopefully the goal of all well reasoned developers out there, is to create application where the components are loosely coupled from each other, and the overall design is decoupled from the tools used to make it.  Relying on TypeMock to achieve this seems like an dangerous bet.  I can still achieve this loose coupling without any tools when I apply Dependency Inversion - it may not be the most enjoyable and I normally use tooling; however, I'm not required to, and should I change my tooling in the future it will be likely be less effort to do so.

One approach that I've used in the past is to use ambient service locators, similar to the Scope<T> sample on MSDN.  This allows you to achieve some of the "aesthetic" (for lack of a better word coming to mind) qualities that I think both sides are striving for.  You can still "inject" your dependencies - but you can do so without relying on the traditional approaches (constructors, methods, and properties).  I strongly recommend you take a look at that sample.

Above all, it is the well-established, time-tested principles that we should want to stick to.  Letting a vendor’s product drive your design and how you achieve adherence to those principles may be an unwise approach.

C# Duck Typing library

Sunday, 19 August 2007 23:10 by jordan.terrell
A friend of mine, David Meyer, recently released the latest version of his Duck Typing library for public consumption.  It's written in C# and the source is available.  I'm looking forward to using it when working with "legacy code" to break dependencies.  Anyways, check it out and let him know what you think...
Tags:   , ,
Categories:   .NET
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Powershell 'dir -r' costs 50 watts of electricity

Sunday, 19 August 2007 22:36 by jordan.terrell

I recently received a pretty hefty electric bill, and I wasn't sure on what all that electricity (cash) was being spent on.  Sure, I speculated, but I wanted to make sure - so I purchased P3 International's Kill-A-Watt Electricity Usage Monitor.  It's pretty cool - it will measure Volts, Amps, Watts, Kilowatt Hours over time, among other things.

I immediatly pluged my computers into it, wondering if they were sucking up all of my electricity.  After being relieved that it was not the source of my surge in electrical expense (I'm pretty sure it was my air conditioner), I decided to see how various things I did on my computers changed my electricity consumption.

I was surprised.  When I compiled a simple C# .NET class library in Visual Studio, my electrical consumption jumped 30 watts while it was compiling.  When I did a recursive listing of everthing on my hard drive using Windows PowerShell, it jumped 50 watts of electricity!  I'm thinking this is because the hard drive has to do additional work, and thus consumes more energy - but it's really cool to put some relative hard number to it.

Tags:   , , ,
Categories:   .NET
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed