Monthly Archives: August 2013

Small (Good) Problem to Have

At my writing meetup yesterday I created a character I just fell in love with, evidenced by every prompt we had I wrote a continuation of the story about her. Falling in love like that hasn’t happened since I was in High School! Which was… not yesterday…

I want to post her adventures here but I need a better place than the regular update stream so I’ll probably be making a page for that.

Security is Based on Trust

“If someone gets into your house they could take your house key, go to the Hardware Store, get a copy made and viola! Unfettered access to your home anytime they want!”

Does that not induce a panic attack? Good! Now how’s about:

“If you give someone your computer they could use Google Chrome to look up all your passwords, take them, and log into your accounts anytime they want.”


Actually, I hope your reactions were equivalent cause the two cases are talking about pretty much the same thing.  Let someone into your home, give them your computer, you are trusting that person to not do anything malicious with that access.  If that trust is broken it is not, I’m sorry to say, really a security problem.

I’d link to the article that inspired this but I don’t want to give it any more hits.

It’s A Stew: 7 Min

Fogs have been think as soup but this one, was a stew.

Soon the morning light would burn the fog away.  Soon I’d be able to see the field and its lonely tree once more.  But for now, there was only white.

Too bad it’s morning, I think.  All these food metaphors are making me hungry for dinner.  Something warm.  Something to help burn off this isolating fog.

I think about grabbing my hair dryer and having a go at helping the sun burn the thick mist away.  Wouldn’t it be cool if you could do that?  Well, this is my story so —

I grab my hair dryer and carve out a fog based igloo.  Indeed, it was as thick as a stew as I was able to make a neat little shelf to put my coffee on as I did my work.  As the sun became brighter above me I delighted in my having the thought to fashion myself a chair so I could enjoy a sit on a cloud before my day really began.

My JavaScript is Showing in my C#

I was working with our in-house dependency injection framework today and I found myself having to:

  1. Temporarily swap out a dependency in an object into a temp variable so I could inject a alternative implementation in for processing, then replace the original value later.
  2. Let another object access the dependencies another object is keeping track of and use a dependency.

So, I wrote a function:

public T GetDependency<T>()
   return (T)_dependencies.Where(d => d is T).FirstOrDefault();

So it just crawls an internal list and when it finds the match for the interface being sought, it returns the implementing object.  Great!  Er, until I needed to work with three dependancies.

I don’t know if this code is going to live, but I wrote another function to solve my problem:

public void GetDependencies(object obj)
   var fields = obj.GetType().GetFields(Instance | NonPublic)
          .ToDictionary(f => f.FieldType, f => f);

   foreach(var dep in _dependencies)
      Type remove = null;
      foreach(var key in fields)
            fields[key].SetValue(obj, dep);
            remove = key;

      if(remove != null)

Then I did this:

var config = new 
   GrabFirstThing = (IFirstThing)null,
   GrabSecondThing = (ISecondThing)null,
   GrabThirdThing = (IThirdThing)null


And thought, “My JavaScript is showing.”  But!  Instead of having no idea what any of the properties of the anonymous object are, as would be the case if I used dynamic (which I can’t because of a mobile target),  they’re type safe and right there.  Now, is the above better than the following from a usability standpoint?

var thingOne = Registry.GetDependency<IFirstThing>();
var thingTwo = Registry.GetDependency<ISecondThing>();
var thingThree = Registry.GetDependency<IThirdThing>();

That I don’t know.  From a performance standpoint, there are a number of strikes against it.  Creating the dictionary, using reflection to set values on an anonymous object.  So I’m thinking now I’ll probably make the change to the three separate calls.

Wouldn’t Dr. Ian Malcom be proud?  And I say this with apologies to Jurassic Park, I got preoccupied with whether or not I could AND I paused to think if I should!