DaedTech

Stories about Software

By

Announcing Disqus for DaedTech

I just wanted to post a note to say that I’m switching from the default WordPress commenting system to using Disqus. So, if you’ve made comments in the past and don’t see them now, that’s because Disqus is in the process of importing all non-Disqus comments stored on my server. Hopefully comments will re-appear at some point in the next day or so.

If you have any problems with the new system, please feel free to email me or to post a comment here.

Thanks!

By

JUnit for C# Developers 7 – Law of Demeter and Temporal Mocking

Last time in this series, I posted about a good reminder of a couple of principles of good object oriented design (respecting the Law of Demeter and avoiding static method invocations as much as possible). Today, I’m going to double back on this consciously a bit to explore some more possibilities in JUnit. Don’t worry – I will fix the design in subsequent posts.

Goals

Today, I’d like to accomplish the following:

  1. Have a mock change with each invocation
  2. Mock a low of demeter violation in as little code as possible

To the Code!

If you’ve followed my last few posts, you’ve noticed that I setup MongoDB. So, logically, the next step is connecting to it with my application, and the next step after that is mocking this connection so that I can unit test the logic (well, since I’m following TDD, technically the mocking comes first). Through trial and error in a throw-away piece of code, I discovered that I could access my database as so:
Read More

By

Home Automation: The Socket Rocket

Introducing the Socket Rocket

A picture of the socket rocketIn the last post of this series, I covered adding a wall switch to a home automation network. Today, I’m going to talk about adding the “socket rocket”, or LM15A. It is commonly known as “Socket Rocket” presumably due to it fitting in a light bulb socket and I guess vaguely looking like a rocket or something. As you can probably deduce from its image, the socket rocket works by having a light bulb screwed into it and then being screwed into a normal light socket itself.

The socket rocket confers a few benefits on users. First, unlike the lamp module we covered in the first post and like the switch we covered in the most recent post, the socket rocket does not announce its working with a loud clicking sound. It turns its bulb on and off silently. Secondly, the socket rocket will work regardless of whether a lamp is controlled by the lamp’s switch, a wall switch, or both. This makes it quite versatile and extremely easy to install, requiring neither replacement of a wall switch, nor even location of the outlet into which a light is plugged. A third advantage is that a series of socket rockets on multi-light lamps allows more granular control over the lights than is possible without home automation. For example, if you had an overhead bedroom lamp with three light-bulbs, you could use socket rockets to have a setting where two of the bulbs were off and one was on. And, finally, the socket rocket can allow control over lights that are generally hard or annoying to reach. This may seem obvious, but an interesting possibility opened up here is the ability to place a lamp in some hard to reach location (up high or on a porch, for example) and control it remotely.

Read More

By

Configuring Fedora and MongoDB

In my last post, I covered installing MongoDB on Fedora. This is another post as much for my reference as for anything else, and I’ll go over here getting set up so that my application successfully uses the MongoDB server.

When I left off last time, I had successfully configured the server to allow me to create documents using the mongo command line utility. So, I created a collection and a document and was ready to access it from my web application. Following the examples in the MongoDB java tutorial, I created the following implementation of my HouseService interface that I had previously hard coded room values into:
Read More

By

Setting up MongoDB on Fedora

This is one of those posts as much for my own reference as anything else, and if it helps others, then bonus.

I installed MongoDB on my old Fedora server just now, and while it was actually pretty straightforward to do, I figured I’d document the steps. The first thing to remember is that there are two separate installs: the client and the server (this is what tripped me up on the MongoDB site’s documentation). There isn’t some deal where running server install also gives you a client.

So, to set up a smooth, easy install with yum, the first thing you need to do is create the file “/etc/yum.repos.d/10gen.repo”. Once you’ve created that file, open it and add the following:

[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0

Now, once you’ve got that in place, run the command, “yum install mongo-10gen mongo-10gen-server”. This will install both the client and the server. When the client and the server are in place, you can start the server by running “/etc/init.d/mongod start”. Finally, if you’re like me, you probably want the server to run automatically. If that’s the case, execute the command “chkconfig mongod on”.

And, you’re set. MongoDB server is installed and running and will also run on your next reboot.