personal, gaming, xbox comments edit

Saturday was a hell of a day.

We got up at around 7:00a and got out of the house basically ASAP so we could get to Jenn’s parents’ house in time to get in their motorhome and head down to Eugene for Jenn’s grandma’s 79th birthday party. That’s like an hour and a half drive, which isn’t as bad when you’re riding in the Adamson Bus, but it’s still a long trip.

We got there and Jenn’s grandma was very pleased to see us. It was a surprise party and the entire family was there.

Now, when I say “the entire family,” I mean like 40 or 50 people. The rockin’ part was that it was raining and we had planned to have the party outside, but instead we had it indoors in a space that was, oh, maybe 500 square feet. You can imagine the chaos - not enough chairs (or enough room for chairs) ended up meaning people sitting on the floor, sitting on laps, standing in the hallway… and it got hot.

So that lasted for about four hours. And the thing is, I like Jenn’s family and all, but I don’t really know anyone and every time we get together it’s like this whirlwind of faces that only look mostly familiar and only results in me being confused and claustrophobic. I don’t really have anything to talk about with them because none of them are tech people and I really don’t follow sports or family gossip. So it’s nice to see them, but I won’t lie, it’s not super duper fun.

After that, we hopped back on the bus and headed home. We got back somewhere around the 6:30p timeframe and on the way home we planned on stopping at my parents’ house because it was my dad’s birthday, too. We got there sometime around quarter to seven, but they weren’t home so I planned on calling him later in the evening. I actually feel bad I didn’t get in touch with him earlier, but he’s going to have to throw me a bone on this one because I was sort of predisposed.

Sunday was errand day so we ran around and did the shopping and so on. Groceries ran far more than I anticipated because we ended up picking up a lot of high-ticket items (cleaning supplies and so on) that we had been putting off. Not great on the pocketbook, but had to be done.

We also picked up one of those automatic cat boxes. We like to occasionally go away for the weekend and the new cat generates a looooot of poop so we want to make sure the box is always clean and doesn’t need to be dealt with for a couple of days at least. We went with the Littermaid Elite after looking at a lot of these things because not only did it seem to be the most popular model, but it also didn’t lock us into proprietary refills or materials beyond the little litter receptacle (which runs about $0.30 each and last around five days - so maybe $2/month, which is better than some of the ongoing costs of the other boxes). The only thing we were afraid of was whether they’d use it.

As I was putting it together, I got to about step seven of ten and had to put the clean litter in the box. I poured it in, turned around, put the litter box down, picked up the instruction manual and turned around to do step eight… but the cat was already in the box taking a fresh crap - even before I got the box put together - so I’m no longer afraid they won’t use it. I couldn’t even finish putting it together before it was used.

Jury’s still out on whether I like it or not. It works great on the clumped-up pee balls, but if the cat poop is… well, soft… it sort of attaches to the rake that cleans the box. I cleaned it off the rake manually the first time, but I left it when I saw it again this morning. I’m going to see if the situation somehow rectifies itself.

I also checked on my sick Xbox, which is on its way home from Xbox Hospital. They are sending me another refurbished machine - it has a different serial number than the one I sent in - so I’m going to end up going through the Xbox DRM problems again. Support actually has a name for this process now - “Points After Repair.” I called them and said I noticed that the serial number was different and that I was disappointed I’d have to go through this again and they were all, “Well, just set up [yet another] Xbox silver account before you call, then when you call in give us your repair number and ask about ‘Points After Repair.’ We’ll hook you up.” Ridiculous. Because that didn’t cause all nature of pain in my ass last time.

testing comments edit

I follow the whole “design-for-testability vs. design-for-usability” debate and, in the interest of full disclosure, I’m a fan of not designing for testability. Part of what I design has to be a usable API and I can’t have a lot of the cruft required in testable design when I get to my finished product.

I mean, think about it - if the .NET Framework was built using design-for-testability, there’s no way like 80% of the people using it today would have been able to pick it up. Considering the inability to solve a FizzBuzz problem, somehow I don’t think having everything infinitely pluggable and flexible solely to support the testing of the framework would have made it any easier to use.

Now think about the notion of the static utility class. Everyone has one (or more) of those classes that are sealed and only provide a few static helper methods. I mean, for .NET 1.1 folks, who didn’t have their own static String.IsNullOrEmpty implementation?

On my project, we have a lot of static helpers that read, process, and cache configuration data. The basic algorithm is something like this:

  1. Check the cache for the data. If it’s there, return it.
  2. Data wasn’t in cache, so open the config file.
  3. XML deserialize the file or do whatever other processing needs to happen.
  4. Cache and return the result.

Here’s some basic sample code: public sealed class ConfigService { private const string CacheKey = “CacheKeyForConfig”; private const string ConfigPath = “/Config/myfile.config”; public static System.Collections.ArrayList GetConfiguration() { System.Collections.ArrayList retVal = null; string configPath = ConfigPath;

    if(System.Web.HttpContext.Current != null)
    {
      retVal = System.Web.HttpContext.Current.Cache[CacheKey]
        as System.Collections.ArrayList;
      configPath = System.Web.HttpContext.Current.Server.MapPath(configPath);
    }
    if(retVal == null)
    {
      if(!File.Exists(configPath))
      {
        throw new FileNotFoundException(
          "Unable to read default configuration file.",
          configPath);
      }

      //... read/process the file... set the return value...

      if(System.Web.HttpContext.Current != null)
      {
        System.Web.HttpContext.Current.Cache.Insert(
          CacheKey,
          retVal,
          new System.Web.Caching.CacheDependency(configPath));
      }
    }

    return retVal;
  }
}

From an API standpoint, it’s a one-liner: ConfigService.GetConfiguration()

But how do you test that? If you’re running FxCop, your static utility class “ConfigService” needs to be sealed. That sort of limits your abilities to mock with several frameworks out there. The simple fact this is a static method is limiting to some frameworks.

Now, granted, you could write a class that provides cache retrieval services specific to this helper and go to the trouble of instantiating that class and… you know what, I’m already tired of typing that out. I don’t need all that. I’ll never sub in a different cache provider for anything other than testing. I don’t want the consumer of the method to even have to know about any of that (so they shouldn’t have to pass the cache instance in as a parameter, for example).

But I do want to have this thing tested. If the object is in cache, does it just return the object without further processing? If it’s not, does it read the file and does it then cache the results? I want the design simple, I want it usable, and I don’t want a lot of moving pieces. In fact, ideally, the code would be about as simple as the sample I posted.

So you need to mock a few things, specifically around HttpContext. (Possibly other things based on the implementation, but we’re going for simple here.)

You can’t really readily do that. Or can you? What if your test looked like this:

[TestFixture]
public class ConfigServiceTest
{
  [Test]
  public void GetConfiguration_NoCache_FileExists()
  {
    //...place a known good configuration in a temporary location...
    string pathToTemporaryConfig = ExtractConfigToTempFileAndGetPath();

    // Set up calls for the cache
    MockObject mockCache = MockManager.MockObject(typeof(System.Web.Caching.Cache), Constructor.Mocked);
    mockCache.ExpectGetIndex(null);
    mockCache.ExpectCall("Insert");

    // Set up calls for the server utility
    MockObject mockServer = MockManager.MockObject(typeof(System.Web.HttpServerUtility), Constructor.Mocked);
    mockServer.ExpectAndReturn("MapPath", pathToTemporaryConfig);

    // Set up calls for the context
    MockObject mockContext = MockManager.MockObject(typeof(System.Web.HttpContext), Constructor.Mocked);
    mockContext.ExpectGetAlways("Cache", mockCache.Object);
    mockContext.ExpectGetAlways("Server", mockServer.Object);

    // Use natural mocks to ensure the mock context is always returned
    using(RecordExpectations recorder = RecorderManager.StartRecording())
    {
      // Ensure any call for HttpContext always gets returned
      System.Web.HttpContext dummyContext = System.Web.HttpContext.Current;
      recorder.Return(mockContext.Object);
      recorder.RepeatAlways();
    }

    System.Collections.ArrayList actual = ConfigService.GetConfiguration();
    Assert.IsNotNull(actual, "The configuration returned should not be null.");
    // ... do other assertions that validate the returned config ...

    MockManager.Verify();
  }
}

Using TypeMock, I was able to easily mock a web context and test this code without having to impact the design or the API usability.

It sounds like I’m shilling for TypeMock, and maybe I am a little. On a larger scale, though, I’m just happy I’m able to get full test coverage without sacrificing my usable API.

And if someone reports a defect with this code? Piece of cake to get a mocked test into place that replicates the behavior and even easier to track down the issue because I don’t have all of these additional unnecessary layers of abstraction to fight through. The code is simple - simple to read, simple to understand, and simple to troubleshoot for the next developer who has to try and fix it. You have to love that.

I’m not sure whether it’s out of necessity or boredom that odd office food concoctions get generated. I know I’ve made up some crazy stuff - some good, some not so good. For example, I know you can’t make Coke Blak by just combining coffee and Coke.

I think it’d be interesting to compile a list of office-based recipes - things you can make with the stuff you find around a typical office (coffee, sugar packets, cup-o-noodles, etc.). I found a recipe for chai tea based on office supplies, though I admit I haven’t tried it yet.

Here are a couple of things I’ve made (try at your own risk, YMMV):

FRUIT PUNCH SODA 1 can Sierra Mist (or 7-Up, Sprite, etc.) 1 packet Crystal Light On-The-Go This is reasonably tasty and a good change from the norm if you like this sort of thing and your office only carries standard soda flavors. Pour the can of pop into a cup and pour the packet of Crystal Light into the pop slowly. Stir slowly with a stir stick until thoroughly mixed, pausing when you see the foam start to rise. If you do anything fast, you’re going to have a mess on your hands.

MOCHA 3/4 mug coffee 1/4 mug hot water 1 packet hot chocolate 2 packets creamer Mix contents together thoroughly and enjoy. The water helps to make chocolate a little more prevalent and make it feel less… thick. Depending on your mood or personal taste, you may just go with the full coffee/no water approach.

ICED TEA 1/2 mug hot water 1 black tea bag ice Put the tea packet in the mug of hot water and leave it. Freaking over-steep it. The tea’s got to be strong because once you take the tea bag out, you’ve got to fill the rest of your mug with ice and let the ice melt, and that’s going to water down the tea. You’ll need to experiment with this one based on personal taste - I like really strong iced tea, so I leave the tea bag in for a looooong time.

SWEET TEA Follow the iced tea recipe but add four to six sugar packets to the tea before adding the ice. (If you remember your high school chemistry, solids generally dissolve better in hot liquids.)

If you have a recipe or link to contribute, leave it in the comments. I think it’d be cool to get a big list of office food recipes.

I love my wife dearly, but sometimes she’s just frustrating. For example, when she has some technical problem (say, with the iPod or the computer) that she needs solved, I’ll come in and help her out, but she gets impatient - as I’m trying to explain the answer, she’s already stopped listening. She doesn’t want to hear why the answer is what it is, she just wants to have her immediate problem solved right now thank you very much.

I do my best to be very pleasant during these exchanges, but it’s exasperating, and it takes its toll on my sanity. Take, for instance, a recent exchange I had with one of my co-workers trying to determine why a particular method was returning a value he didn’t expect:

Travis: Okay, so the thing is returning this answer to you because – Michael: I need to know how to get it to return this other thing though. T: Right, but after that, you’re going to need to know how to – M: But how do I get it to return the answer I want? T: Well, you have to do set this parameter this way before you can – M: That sounds really complicated. I’m just trying to do something simple. How do I get it to do what I want? T: I’m getting to that, but there are a few steps that – M: I’m already not listening. What if I just type this in here and hit this button? [He types something in and hits the button.] T: Um, that’s not going to – M: Hey, that’s not working. What about if I try this other thing and hit the button? [Types this other thing in and hits the button.] T: That’s not going to – M: It’s not working. I don’t understand why it’s not working. I just need it to – T: [Exasperated] Look, hon, I can’t tell you how to do what you want to do until you stop and listen to me. M: [Silence] T: I just totally called you “honey,” didn’t I?

Yeah, I did. It was exactly like one of the exchanges I’ve had altogether far too often with my own very loved - but very impatient with technology - wife.

It got really hot in that cubicle for a couple of seconds. And then we laughed our asses off.

process comments edit

I understand that the IT department does their best to help people solve problems and offer services that improve…

You’re asleep already, aren’t you?

Okay, the short version: The company IT department is a good thing, and what they do is meant to help. I’m totally on board with that. I used to be in the IT department. We weren’t out to screw you, I promise.

Here’s the deal, though:

There are a certain quantity of problems that need to be solved, and your computer has a fixed amount of capacity to solve them in. Your disk isn’t getting any faster, your CPU isn’t going to magically process at an extra gigahertz faster. You’ve got what you’ve got. With that, besides getting work done, you probably also want to:

  • Back things up - It’d be a shame if you lost your work.
  • Stop the spread of viruses - You don’t want to get infected, now, do you?
  • Keep company data secure - If someone breaks into your car and steals your laptop while you’re picking up donuts for the morning meeting at the store, they shouldn’t get access to your proprietary data

Each of those things are valuable, but they also eat resources on your system. In some cases, not a trivial amount, either.

I have a 1.7GHz processor and 1.5GB of RAM. It’s not a super powerhouse, but it should be enough to get the job done. It took me eight full minutes to boot up and log in this morning, and my machine is still tanked. Why?

Say you’re getting ready to ride in a bike race. Your computer is your bike. “We got you a pretty decent bike,” says IT, “This bike will definitely get you over the finish line.” You look the bike over, check the specs, and take it out for a spin. Hell, yeah, that bike will do the trick.

“Now, it’s a long race, so you’re going to need some supplies. We’re here to help you,” says IT. And they are - it is a long race, and you do need some supplies. You’re thinking maybe a couple of energy bars and some water.

“First we’re going to strap this 30 gallon drum of water on your back. Yeah, it’s pretty heavy, but you have a fast bike. Oh, and in the event you need to take a break and get off the bike, you don’t want the bike rolling away (?!) so here’s an anvil. It’s okay, though, you have a fast bike. Oh, and we know the first leg of the race is basically a huge hill, but later in the race you’ll want more high gears, so we replaced all of the low gears with high gears so you don’t have to pedal as hard later on. But you have a pretty fast bike, so it should be okay.”

You struggle onto your bike and it barely moves. No one seems to be terribly concerned about this, though, because, crap, man, you have a fast stinking bike so it has to be you causing the issue. And if you complain?

“Yeah, um, I need some water, but I really don’t think I need a drum of water - I only need a water bottle.”

“Well, you can give us back the drum of water, then.”

“Can you give me a water bottle? I do need water, just not a drum.”

“Um, no - all we have is a full drum of water. If you only want a bottle, you’re on your own.”

Thanks.

The cumulative effect of the daily incremental backup, real-time virus scanner, real-time disk encryption, and everything else that runs in the background to help me out is killing me. I booted up this morning and with the startup cost of all of these services, I’m surprised they don’t send someone downstairs to personally punch me in the junk every morning, too. I mean, think about it - whenever I read or write a file, it goes through both a real-time AES 256 encryption and the real-time virus scanner, neither of which I have control to configure because it’s all centrally administered “for us.” I look sideways at this thing and the CPU is pegged and the disk light is on solid for three minutes.

But, hey, if I don’t want to suffer the cost of the incremental backup software (that runs for probably an hour each morning), I can uninstall it. Is there any other backup mechanism? No - if I uninstall it, I’m on my own. Or I could set it to run when I’m not at work… but, oh, wait, you need to be connected to the network to have it run, and the whole point of my having a laptop is so I can take it home with me at night and work disconnected if I need to. There’s no time when I’m not working on my computer that it’s connected to the corporate network. (Not that it matters; I only have about a 30 - 50% success rate on completing a backup at any given point anyway.)

Don’t get me wrong, I appreciate what the IT department does for me and they’re a necessary piece of the puzzle. I just feel a little anchored down lately by all the help, is all, and I don’t think folks consider the overhead of all of these helpful-but-necessary services before rolling them out.