A rolling blog gathers a lot of knowledge

Most times I see myself as a giant katamari and the internet is all stuff I can just roll over, pick up, and make my brain grow bigger. This blog isn’t one of those things, but the article linked here is.

Michael Feathers has a great article on what he calls “sensing variables”, variables introduced into a long piece of code that can be used to verify refactorings. In a nutshell (hey, how did I get into this nutshell?) it captures the state of something for recovery later and allows you to introduce refactorings (say rearranging code) with the comfort that things haven’t changed without your intent.

Very cool as it’s always difficult to find a way to know the state of things when you’re trying to program for a stateless environment. The other thing is that while unit test rock my world, I find it very difficult sometimes to get them to poke and prod into classes to see what’s going on. I only rely on public properties and methods (I don’t believe in the reflection gig trying to test private accessors) and try to stay away from “out” parameters as often as I can (I really don’t like knowing a variable goes in one way and out another without knowing what’s going on in between) so I can only test what’s returned. Often it’s hard to write a test that really gets at the heart of what’s going on, without exposing everything and blowing off basic tenets of OO like encapsulation.

Anyways, great article and simple technique for this kind of thing. It’s easy to implement and works well so feel free to check it out here.

No Comments