Using IoC containers in .NET projects is steadily increasing in popularity and there are a lot of different containers to choose from. Another thing that is very popular among .NET developers is ReSharper, and there are some warnings that ReSharper issues (“Class ‘xyz’ is never used”) when analyzing code that contains classes that are registered in a container and then injected into its consumers at run-time.

To help developers getting to the “warning-free nirvana” there is a plugin for ReSharper called Agent Mulder. What it does is that it makes use of the in-memory structures that ReSharper maintains and searches for places where concrete implementations (classes) are registered in a series of potentially used IoC containers. It will mute the ReSharper warning and it will also provide means of navigating between the implementation and where it’s registered as well as the other way around (from a registration to the types that are affected by the registration instruction).

I sat down today and tested the Agent Mulder plugin in a little test project in which I decided to use Autofac and – the plugin works as advertised!

However, there is one tiny little problem. When writing code, specifically concrete implementations I tend to use that ReSharper warning mentioned previously as a safety harness. What it tells me is that there is no place in the code where this class is explicitly instantiated, i.e. – it is only consumed by means of resolving it via the container. Agent Mulder won’t complain about the fact that a class that is registered in a container also happens to be explicitly instantiated.

Bottom line: Agent Mulder removes ReSharper warnings which we don’t want to see when we’re doing everything right, but as soon as we begin to make mistakes we get no notification of this. I believe that Agent Mulder could be an even better plugin if we as developers were warned when we’re about to make a mistake by not using the container introduced into the project.

I would like to stumble into the pitfalls of success. =)

Share

Comments Comments Off

I’ve been running NCrunch for quite some time now and I’ve grown to like it. How ever, they’ve decided to charge $159 for a single named user license. This prompted me to have a look at the competition, specifically Mighty Moose.

The first difference I notice after installation is that Mighty Moose gives no feedback on a per line basis. The argument from the developer of MM (Greg Young) is that if you’d need that feedback your method is likely too large and complex anyway, and that you should refactor your methods so that you can keep a clear picture of all the code paths in it. What is shown with the implementation is instead a circle indicating the risk of potential breakage if changing that specific method (it’ll show green, yellow or red). These are called risk margins.

The risk margin indicators make sense, and I’d probably come to the point where I’d use them to make better decisions about changes in code. I work as a consultant, so as Greg Young himself points out, we spend a lot of time in other peoples code. What doesn’t, to me, make sense though is that we don’t seem to get any feedback in the gutter when looking at an implementation as to whether or not the tests covering it are passing – or not. When making a test fail by changing something in the implementation all risk indicators are still green. I find this to be slightly counter intuitive, I would expect a failing test to override and tell me that something has gone wrong. How ever, should you open your test class you will get red crosses in the gutter next to the tests that are currently failing.

Thinking about this from a TDD point of view it confuses me even more. Let’s imagine I want to create the actual implementation of an interface, but before I do that I create a bunch of tests that will fail. When switching to my new and empty class I’m shown a risk indicator that tells me that everything is OK, even though there are failing tests. As I go along and implement features described by my tests there’s no feedback on how I’m doing.

In order to get information on the state of your tests you need to bring up the ContinuousTests window (Ctrl-Shift-Y,G), shown there is a list of the tests that are failing. Some neat features with that window is that you can navigate in that list and bring up more information (I) or debug the highlighted test (D).

So, it seems to me that the point of running tests continuously (in order to give continuous feedback) is kind of missed given that the feedback Mighty Moose has is only found by giving up screen real estate (for a permanent display of the ContinuousTests window) or by taking deliberate steps to check on your tests. The latter alternative is basically identical to invoking your test runner – that which we wanted to avoid by using a continuous test platform.

After all this, are there no nice things with Mighty Moose? Well, yes. There’s the static and dynamic analysis graph and there’s the sequence diagram. But these things do not make a sleek continuous test runner in my eyes.

Seems that I’ll have to get the license for NCrunch.

Share

Comments 3 Comments »

After I got myself a proper iPhone mount for my motorcycle I’ve been using Waze on a regular basis. But after upgrading my iPhone to iOS 6 it started exhibiting a weird behavior, it seems that Waze isn’t getting a continuous stream of location data from the phone. It manifests itself by showing a red bar in the top of the window saying that no GPS data is available and that it’s showing an approximate location instead.

Up until now the only remedy I’ve found is to disable and then re-enable the location services (either for Waze specifically or all together), this morning I had to do it twice though. Let’s see if there is an update to either iOS or Waze that can take care of this annoyance, ’cause otherwise I really like Waze!

Share

Comments Comments Off

So, yesterday I wrote about some of the great prepared virtual appliances you can get your hands on for no cost at all. One of these is the Turnkey Revision Control server appliance which I wanted to use for a local git installation. The first start up of the appliance was absolutely problem free, however I got into some problems when trying to create my first git repository on the server. And now that I’ve got them all ironed out I thought I’d share them with anyone else who might run into these in the future. I’m guessing that most of you readers out there are interested in the solution to the errors you’re experiencing, there fore I’ll structure this blog post with the errors as section paragraphs.

 

fatal: ‘/git/<repo>’ does not appear to be a git repository

This occurs when you try to clone a repository via the SSH protocol rather than the unsecured git protocol. The reason for this is that the default shell path when your SSH client logs in on the server (which is what happens behind the scenes when cloning via git) is not relative to the path where the repositories are stored. The solution is to adjust the URL so that it is relative to the root of the file system on the git server:

# URL for cloning via git:

git://<turnkeyServerName>/git/<repoName>

# URL for cloning via SSH:

ssh://<user>@<turnkeyServerName>/srv/repos/git/<repoName>

 

No refs in common and none specified; doing nothing.

This is most likely because when you created the repo you added no items to it before cloning it, hence your git client won’t know what branch to push. Easy solution? Add a first item to the repository before anyone clones it, like so you’ll get a master branch which will be automatically tracked by cloning clients.

 

error: insufficient permission for adding an object to repository database ./objects

You’ll see this when trying to push to your new repository on the server and if your user is lacking write permissions in the .git folder on the server. What worked for me was to move to the .git folder for your specific repository on the server and issue the following commands:

chmod -R g+ws *

chgrp -R <groupName> *

There are of course a million ways to handle file system permissions and this is just one of them, but in the end the error is due to permissions not allowing writes.

 

[remote rejected] master -> master (branch is currently checked out)

Should you encounter this error you’ll probably have seen a quite verbose error message talking about things like “bare repositories” and “receive.denyCurrentBranch”. This error occurs because the repository on the server doesn’t just contain the repository binaries but also a copy of the actual files contained within the repository. It might sound weird, but what it basically means is that the server is set up just like your co workers machine would be and should you push to the repository on the server the working directory (on the server) is going to be very out of sync with the repository. Solution? Well, the first might be to create bare repositories on your server, but I haven’t experimented with that yet so I don’t know. Until then, you could issue the following command (which is also specified in the error message) on your server while in the repository folder:

git config receive.denyCurrentBranch ignore

 

Your repository isn’t visible in the git web application

To make your repository visible in the git web application (https://<turnkeyServerName>/git) you’ll have to make a file system link with the following command:

ln -s /srv/repos/git/<repoName>/.git /var/cache/git/<repoName>.git

 

Unnamed repository; edit this file ‘description’ to name the repository.

Now that you’ve managed to get your new repository to show up in the git web application you’ll quickly realize that the default description pops up here. Simplest way to update it? Move to the .git folder for your repository on the server and issue the following command:

echo ‘<description>’ > description

This will change the contents of the description file and replace it with what you echoed out to it.

 
I hope that this is all you’ll need to get started with your new git version control server.

Share

Comments Comments Off

A couple of years ago I evaluated which virtualization platform I would use on my MacBook Pro. I tried  a couple of alternatives, namely: Parallels, VMware Fusion and also VirtualBox. I ended up using VMware Fusion for my virtual Windows machines because I found that some of the integration features with OS X felt a bit tidier than in Parallels.

Yesterday however I found another reason (Turnkey revision control) for using VMware Fusion: there are a lot of prepared appliances out there on the internet ready for use and they are downloadable in a VMware format! I assume that Parallels and its likes have the ability to import VMware disks, but the feeling of just downloading the appliance and clicking the start button without any hassle. Awesome! =)

Share

Comments Comments Off

Want to get as much as possible out of the video coverage of the 2012 Dakar rally from ASO? Finding it hard to get to the good stuff over at http://www.dakar.com? Well, in that case I’ve got it all sorted for you. Below you’ll find a list of all the English videos posted by the official Dakar organization on YouTube – in a structured manner! At the least I’d recommend watching the Stage summary and the Magazine for every stage, however all the other material is really interesting as well! The Stage summary is usually around three minutes long, and the Magazine is about a minute and a half. What I find is a real pity is that none of the material is available in HD, the nature shots would’ve been awesome in a better resolution and bitrate. Oh well, can’t have it all without being there I guess. =) Here goes:

Stage #1 Mar Del Plata – Santa Rosa de la Pampa
Stage summary http://www.youtube.com/watch?v=EvccXYnHRVg
Magazine http://www.youtube.com/watch?v=5mozodCWwwg
Interview stage winner http://www.youtube.com/watch?v=QhdcjYczBpg
Landscape of the day http://www.youtube.com/watch?v=xpttChVPFxc
Image of the day http://www.youtube.com/watch?v=ObbcbLBbCFg
Legend http://www.youtube.com/watch?v=w-r6ZHtTodE
Stage #2 Santa Rosa de la Pampa – San Rafael
Stage summary http://www.youtube.com/watch?v=xNlAki_VpDs
Magazine http://www.youtube.com/watch?v=hRuPneXyX5M
Interview stage winner http://www.youtube.com/watch?v=-8fTWK6majw
Landscape of the day http://www.youtube.com/watch?v=IKYYZRFI2PM
Image of the day http://www.youtube.com/watch?v=9XCZAAagkwE
Legend http://www.youtube.com/watch?v=sHx9eTxJTsg
Stage #3 San Rafael – San Juan
Stage summary http://www.youtube.com/watch?v=AfFMfA0IqiE
Magazine http://www.youtube.com/watch?v=iL5Iazv6_t4
Interview stage winner http://www.youtube.com/watch?v=AsBHA0QTL6M
Landscape of the day http://www.youtube.com/watch?v=l-SDIhTCrRQ
Image of the day http://www.youtube.com/watch?v=wjkHGs2NhXs
Legend http://www.youtube.com/watch?v=Ffi7at2pono
Stage #4 San Juan – Chilecito
Stage summary http://www.youtube.com/watch?v=8CkbtfEK1ds
Magazine http://www.youtube.com/watch?v=m_qRYnZ6cL0
Interview stage winner http://www.youtube.com/watch?v=J0cfNgFsGss
Landscape of the day http://www.youtube.com/watch?v=Ss2k8gu8L7k
Image of the day http://www.youtube.com/watch?v=PN7Sd9eZCCc
Legend http://www.youtube.com/watch?v=MQtyZcBUk28
Stage #5 Chilecito – Fiambala
Stage summary http://www.youtube.com/watch?v=G-TGcS_7wPM
Magazine http://www.youtube.com/watch?v=InyG5pLIIsE
Interview stage winner http://www.youtube.com/watch?v=ENw4mDKmANc
Landscape of the day http://www.youtube.com/watch?v=qr2u4PBOkhs
Image of the day http://www.youtube.com/watch?v=TgG-uol75gA
Legend http://www.youtube.com/watch?v=5VGmjMvU6OQ
Stage #6 Fiambalá – Copiapó (cancelled)
Stage summary
Magazine http://www.youtube.com/watch?v=JUUY8YfFLjA
Interview stage winner
Landscape of the day
Image of the day
Legend
Stage #7 Copiapó – Copiapó
Stage summary http://www.youtube.com/watch?v=qUsy0Z91O8s
Magazine http://www.youtube.com/watch?v=6n0tXZ_0tjw
Interview stage winner http://www.youtube.com/watch?v=gMPtdMayuEU
Landscape of the day http://www.youtube.com/watch?v=dplAEUSLYnA
Image of the day http://www.youtube.com/watch?v=HewrmfL3I4A
Legend http://www.youtube.com/watch?v=GgOXrQMOf4k
Stage #8 Copiapo – Antofagasta
Stage summary http://www.youtube.com/watch?v=oS1ONeBaSBs
Magazine http://www.youtube.com/watch?v=nllPwuXFo_I
Interview stage winner http://www.youtube.com/watch?v=wowX8e-vs_E
Landscape of the day http://www.youtube.com/watch?v=ZHjLjhYXY0w
Image of the day http://www.youtube.com/watch?v=BIj5vDFqZzQ
Legend http://www.youtube.com/watch?v=ovY3xofvOD4
Stage #9 Antofagasta – Iquique
Stage summary http://www.youtube.com/watch?v=XBuOsa1MtV4
Magazine http://www.youtube.com/watch?v=DR9ZD8nxE_g
Interview stage winner http://www.youtube.com/watch?v=F8DDNwH1-20
Landscape of the day http://www.youtube.com/watch?v=EJt_M-SivgQ
Image of the day http://www.youtube.com/watch?v=PWfq1A3ecAg
Legend http://www.youtube.com/watch?v=pcGIfIa1AgY
Stage #10 Iquique – Arica
Stage summary http://www.youtube.com/watch?v=ZTtGAdw6nVg
Magazine http://www.youtube.com/watch?v=c-UYsBvfViI
Interview stage winner http://www.youtube.com/watch?v=Ff0gNejQ6Tk
Landscape of the day http://www.youtube.com/watch?v=ceu888H2Jkw
Image of the day http://www.youtube.com/watch?v=mzNSu5tMZDU
Legend http://www.youtube.com/watch?v=yNjhqlyWyuI
Stage #11 Arica – Arequipa
Stage summary http://www.youtube.com/watch?v=49BrJqP_KrI
Magazine http://www.youtube.com/watch?v=4P4NatRhrbQ
Interview stage winner http://www.youtube.com/watch?v=MyA1t-gVDyI
Landscape of the day http://www.youtube.com/watch?v=v_6Lu1Om9ss
Image of the day http://www.youtube.com/watch?v=Tdrd0WnhbCw
Legend http://www.youtube.com/watch?v=X_cYb0wSGQg
Stage #12 Arequipa – Nasca
Stage summary http://www.youtube.com/watch?v=_cXZrzAshhE
Magazine http://www.youtube.com/watch?v=g-oI9WPeHro
Interview stage winner http://www.youtube.com/watch?v=zTWaDC4oRzk
Landscape of the day http://www.youtube.com/watch?v=J59LWOd2ZLg
Image of the day http://www.youtube.com/watch?v=3CpQANn42sw
Legend http://www.youtube.com/watch?v=IOEMQtp33MA
Stage #13 Nasca – Pisco
Stage summary http://www.youtube.com/watch?v=M3-AZw3TB_g
Magazine http://www.youtube.com/watch?v=9qiHRmtUUkA
Interview stage winner http://www.youtube.com/watch?v=2q1RaUR_GjA
Landscape of the day http://www.youtube.com/watch?v=dBdBb7Fk4UU
Image of the day http://www.youtube.com/watch?v=W8L-rbya1k4
Legend http://www.youtube.com/watch?v=1Ehbq3nEBTE
Stage #14 Pisco – Lima
Stage summary http://www.youtube.com/watch?v=XrraIa6Kckk
Magazine http://www.youtube.com/watch?v=us838D3EzXk
Interview stage winner http://www.youtube.com/watch?v=1bP48Z7ErZM
Best of bike http://www.youtube.com/watch?v=ljkeNZPRYDU
Best of car http://www.youtube.com/watch?v=hzzTmqP5Jo8
Share

Comments Comments Off

Just saw the season finale of the new series Homeland and I’ve got to say that it’s a really good series! It’s managed to keep me more on edge during the whole first season than a lot of other series. Up until the last episode of this season they kept an intriguing story line with a few unanticipated twists left right to the end, aka – cliffhanger.

I’ll be waiting for season two now! :)

Share

Comments Comments Off

Recently I came across a situation in Argentina where we needed to fill up our car with gas, but none of the gas stations around had any. Given that we were on a road trip through Patagonia our knowledge of the local surroundings was limited to a paper map and a TomTom device with a few points of interest.

As you’ll read later on, this situation presented quite a lot of uncertainty, and my learnings on how to create certainty could be summarized like this:

  • What information do we have?
  • What is our current goal?
  • What information do we need to achieve our goal?
  • How do we get that information?
  • What is our alternative plan?

It all began with our arrival at a Petrobras station in Sarmiento with a half full tank. Pretty soon it became clear that the gas station had run out of gas, but a local was quick to help out with the information that the gas station in Facundo (about 90 kilometers further in the direction that we were travelling in) had gas available and that the refill in Sarmiento wouldn’t arrive sooner than 1,5 hours. Knowing that one full tank of gas takes us approximately 440 kilometers we knew that we’d easily reach Facundo on what we had left. So, we drove the 90 kilometers to Facundo only to arrive in a town that never had a gas station (and probably never will). Yet another local in Facundo told us that we ought to travel even further along the road to Gobernador Costa, claiming that we would easily make it there with our, now quarter full tank. A quick check on the paper map revealed that the distance to Gobernador Costa was way longer than we’d manage on what gas we had left now. So we decided to drive back to Sarmiento. Slowly.

Back in Sarmiento it became apparent that the refill of the gas station had not occurred, and now we only had about 3-4 liters of fuel left in the tank.

That pretty much sets the scene. Stuck in Sarmiento:

  • with 3-4 liters of fuel (consuming approximately 1 liter per 10 kilometers),
  • no gas at the Petrobras station,
  • no gas at the YPF station about 500 meters down the road either,
  • time was about 4 pm,
  • rumors of gas available at Villa Hermoso,
  • an uncertain possibility to get a room at a hotel (a sign at the side of the road hinted of a hotel in Sarmiento).

There are different ways of approaching a situation like this, of which the least effective one is to act passive and resort to raising “what if…” questions. Those could be “What if there is no refill today?”, “What if we need to stay here over night?”, “What if there is no gas i Villa Hermoso?”. Basically, a lot of “What if”-s and no signs of devising a plan.

Instead of being ruled by passiveness we decided that being proactive and get an action list in order with the ambition to be able to act on it immediately would be the best thing to do. What information do we have? What is our current goal? What information do we need to achieve our goal? How do we get that information? What is our alternative plan? Breaking it down:

What information do we have?

What we knew is more or less described in the previous bullet list, so nothing more to add here.

What is our current goal?

In this case it was rather simple to answer that question: to fill up the car with gas as soon as possible. But given other circumstances (or facts) it could already have been something like “get a room for the night”.

What information do we need to achieve our goal?

This section, and the next, is probably the most interesting ones in this blog post since they aim at attacking the primary problem at hand by breaking it down with a series of very concrete questions and actions. In this particular case:

  1. How far, exactly, is it to Valle Hermoso?
  2. Does the gas station in Valle Hermoso have gas?
  3. Can we get to Valle Hermoso on what we have left in the tank?
  4. Will any of the locals sell us gas?
  5. How much gas would we need to get to Gobernador Costa?
  6. When will the gas stations in Sarmiento get a refill?
  7. Can we execute the actions for answers to any of the questions above in parallel (yeeeees, very geeky)?

How would you arrive at a list like this? You just need to take the “What if”s that are floating around and make proper questions of them. Sure, a few of the questions above are the result of previous questions, but all in all it’s not hard for a human being in need to come up with questions. The only real effort here is to prioritize the list so that you start working on the most important part first.

How do we get that information?

I’ll re-use the numbers of the questions above for clarity:

  1. Our paper map had pre-calculated distances printed and our TomTom device also had Valle Hermoso entered as a location, so this was a fairly simple procedure. The answer turned out to be about 65 kilometers in the direction we had first arrived from.
  2. This turned out to be a bit more tricky since you might not always get correct information from people. This isn’t because they want to harm you, it’s just that they do actually want to help you. So they might feed you crappy information just to keep up the appearance of being knowledgeable. The simple solution here is to ask multiple persons and to compare their answers. We ended up with the following data:
    • Random person in a pick up truck: “No, there is no gas station at all in Valle Hermoso!”.
    • Other random person in a sedan: “Yes, there is a gas station!”. This answer prompted me to further qualify the accuracy of that statement by asking “What company is it?”
      • Rather quickly I got the answer “YPF!”.
    • Two guys on motorcycles with small tanks: “Yes, there is a YPF station in Valle Hermoso, but it’s run out of gas as well.”. Being a motorcyclist myself I happen to know that bikers usually keep track of their fuel status and where to get more fuel. They both answered my questions more or less in unison, so I knew that the information would be pretty accurate.
  3. Being fairly confident that there is no gas in Valle Hermoso this question is now redundant (but no, we wouldn’t have gotten there with what we had left).
  4. Turns out that one local offered to check for gas in his home and return within one hour. One thing if importance to note here is that due to the language barrier (and probably stress) it was not agreed upon whether or not he would return regardless of what he had at home. This resulted in us waiting for two hours. Just to be sure.
  5. Using the paper map and the pre-calculated distances we gathered that 20 liters added to our tank might just be enough to get us there.
  6. Getting our hands on this information would of course have been very nice, how ever given the track record of previous “help” from locals and the limited amount of gas station attendants we knew we’d probably be fed inaccurate information without the possibility to cross check. And yes, later it turned out to be inaccurate.
  7. Yes! Whilst trying to rustle up some fuel from any locals passing by (#4) we also stopped and talked to people coming from various directions (#2) while at the same time analysing the maps for distance information (#1 & #5).

What is our alternative plan?

Looking at the information gathering process above and checking the current time it soon became pretty obvious that we’d need to get a hotel room, and in the end that’s what we ended up doing. To ensure that we’d actually get a room and not have to sleep in the car we decided that we had to start finding a room pretty soon, otherwise everyone else would’ve gotten to the rooms before us. Having the alternative plan ready and knowing when to act on it is necessary in order to stay one step ahead. Your alternative plan might not be one you like, but get yourself warmed up to the idea and don’t ignore it. In total we stayed in Sarmiento for about two and a half days. Each and every day one of us in the group would check around the gas stations to see if there were any news regarding a refill. Other than that there’s nothing much to do other than accepting the facts of life and that every other option has been identified and worked on.

Wrap up

It all ended on a Monday morning when after having decided that we’d arrive early and be first in line at the Petrobras station for the delivery that most likely would arrive that day. The ironic ending to this story is that while sitting in the car at the Petrobras station we saw a truck from YPF pass on the main road. It looked like it was heavily loaded and luckily another member in the group who had already begun walking towards the YPF station for information could call us and confirm that the truck was pulling in. So we decided to abandon Petrobras and bet for success at the YPF station. And success we had!

Share

Comments Comments Off

A couple of days ago I got a flat tyre on my bicycle. In and of itself that’s not really a big problem, I consider myself handy enough to fix that myself. However, what was a problem was time; I really needed my bike the next day and for the rest of the week and I didn’t really have any time in my already busy schedule to fiddle around with a punctured inner tube. Also, I don’t have a clue as to which sizes of inner tubes there are and if there is a chance of me getting the wrong one.

So I decided that I would only bother with taking the wheel off the bike and then let someone else fix the flat tire using any means necessary. This seemed very reasonable partly because there is a bicycle shop around the block from where I currently work.

So at 10 am when the shop had opened I went over to see if they could help me. Little did I know that in three minutes flat and 170 Swedish krona later I was equipped with a new inner tube mounted on my wheel – ready to be put back on my bike!

The moral of the story is basically this:
Realize that there are people more skilled than you and let them do their job so that you get more time to do your job (or whatever you happen to value most right then and there). Everybody wins! Those 170 Swedish krona are probably the most well spent money I’ve put into that bike!

Share

Comments Comments Off

It’s like giving a gun to a monkey, very dangerous!

-Borat

Share

Comments Comments Off