Amateur Video, Candy, Diet Coke == $10 Million

These two guys in Maine took the fact that a Mentos candy dropped into carbonated soda will produce a gusher if done right and then proceeded to produce their own version of the Bellagio water show with 101 2-liter bottles of Diet Coke and 523 mentos candy.

Mentos estimates that they’ve received $10 million of free publicity from the video that has shot up the charts on YouTube. They might also do a deal with these guys as well. It’s amazing what a little imagination, timing and the Internet can do these days.

What a Crappy Blog Entry

Trying to stay in Tinou’s theme of crappy things I thought I’d talk about his entry, “Spring, what a crappy framework”. The main thing here is that the example points to bad design more than it does why Spring is a crappy framework (it’s not but even if it was). I could easily make that a good design as well and Spring has nothing to do with either approach. I have yet to see how Spring encourages bad design. Rather, it encourages it I believe. Tinou pointed this out as well with respect to encouraging the use of interface driven design. Maybe people are just trying to impose Spring where it’s not supposed to be used within his organization. Pushing a tool where it doesn’t belong is bad no matter how or where it happens. I don’t know, though. Some complain it encourages over complicated configuration. Maybe it’s better to have complicated configurations than it is to have that complication moved into code which tends to be complicated enough as it is.

Now, the configuration. Let’s face it, complex applications are going to have complex configurations. Over time you can simplify them or move towards a configuration through convention approach that Rails has been championed for but it’s always going to start out a little more verbose than it might need to be. In Spring 2.0 it moves forward with the use of XML Schema. Combining that with its support for “components” and you will start to see configurations get less complicated. It will also depend on how you manage your configuration files as well. I know that most people don’t think about this because when I ask people in interviews how they manage complex configurations I get blank stares. Almost every time. I generally tend to break my configurations in to multiple files based on functionality silos. Yes, there are a lot of files but if you know you need to find something about the query factory and/or library then you go to applicationContext.queries.xml and there it is (see, more convention!). Complexity is going to go somewhere and as long as you are consistent and follow your own conventions then its maneagable. I also use Spring BeanDoc to view my Spring configuration and how everything ties together. In addition you can also use the Eclipse Spring IDE (note — the site seems to be down right now) plug-in to help better manage your configuration.

Sometimes you just need to figure out where your problem really lies. It’s not always the tool. Tools can all be misused and most of the time the problem lies between your ears more than in your computer.

Snakes on a Plane!

Can you imagine a more campy sounding movie title? Well, it’s coming! Snakes on a Plane is coming on August 18th this year. I think we’re going to go at lunch from work. See the whole history here. Supposedly they went back to filming for 5 days to get a Samuel Jackson quote that everyone had been clamoring for.

I can imagine a great SNL skit take-off: “Bushes on a Plane!” Conservatives unleash the Bush family members (don’t forget Barb!) on a plane of unsuspecting liberals to try and take them down!

Laura, I’m putting this thing in reverse

Imagine George Bush saying this to Laura as he backs up the car that we’ll call civil rights.

That’s what’s he doing with this election year pandering otherwise known as a constitutional amendment to make gay marriage illegal in the United States. At its best it’s just pandering for voter turnout. At its worst it’s Bush and company’s attempt to push something through when everyone else’s attention is focused on other issues that are considered more important.

How such a large group of people in our country can be prejudiced against another group is beyond me. How they actually think this threatens the family concept in our country is even more mind boggling. And don’t tell me that this is just about restricting marriage of homosexuals. This is the first step that the conservative right wants to take against them. Just why are people so offended and scared of people that live a different lifestyle from them? I know lots of homosexuals and I have yet to meet one that has tried to convert me to be gay. On the other hand I’ve met lots of christians that have tried to convert me. Hmmm…makes you think, heh?

I’m surprised a “Visit Canada (And Stay There)” ad campaign targeting homosexuals isn’t next. Of course, I’d expect it to be funded by the Christian Coalition, no less.

Bookmark Synchronization on Firefox Part Deux (With Google)

Thanks Google! (Sarcasm alert, sorta)

Wouldn’t you know it, after I spend time getting Foxmarks working on my own server and then documenting it, a friend sends me an e-mail this morning alerting me to the fact that Google Labs just released Bookmark Sync that will store bookmarks, tabs, cookies, history, etc. in my Google account. I installed it this morning and it’s pretty sweet. I opened a bunch of sites, then closed Firefox and opened it up on another browser and it restored everything from my other browser. It’s actually pretty cool.

The downside…startup time is really slowed down a lot. It syncs everything at startup and even on a relatively fast connection (our 100 Mbps pipe won’t be active until next week) it took 20+ seconds.

Google encrypts passwords and cookies so with a pin you designate that is separate from your password so that’s cool. So far it seems to work pretty easily. I’ll try it out and see how I like it compared to Foxmarks.

At least I have a couple of options now for synchronizing bookmarks between computers.

Bookmark Synchronization on Firefox

Those of you out there that work on multiple computers, for example a work computer(s) and personal computer(s), know how much of a pain it is to keep your bookmarks synchronized. Over the years I’ve built a pretty large library of bookmarks. What makes it annoying is that I’ll add a bookmark on my home computer, for example, then go to work and realize that I need the link that’s on my home computer. What I’ve done in the past is just e-mail my bookmarks.html file to myself but synchronizing it and keeping it up to date is just not a lot of fun.

I could use del.icio.us and while I do have an account on there I don’t want it to be my primary bookmark store. I tend to prefer having my bookmarks be private and on my computer.

I figured their had to be a Firefox plugin that took care of this. I know I’m not the only one to have this problem. I found a few of them including OnlineBookmarkManager and FoxMarks. I didn’t get that far in to the OBM extension because I found that FoxMarks just uses WebDAV to push and pull bookmark files. Perfect! But where would it store them? I really don’t want to store my bookmark file on a 3rd party server, especially one that could go down at any time since both initiatives look more like hobby sites than being attached to a more permenant entity. Plus, there’s just the privacy issues. Enter Apache and mod_dav and mod_dav_fs.

So, I set out to configure WebDAV support on Apache. At least on my distro on my VPS at RimuHosting (tell ’em I sent you if you sign up!) the Apache configuration comes with the DAV modules loaded, although no directories are configured for DAV support. You’ll want to look for these lines in your httpd.conf file:


LoadModule web_dav.so
LoadModule web_dav_fs.so

If they’re not there, make sure the shared objects are present and then add the references to them in the file. If you don’t have the referenced files then you’ll need to do more research to get your server configured for WebDAV support.

After this you’ll want to create a directory in your HTML folder. Let’s just say you call it /bookmarks. Create that directory and then make sure that the user that the httpd process runs as has the ability to write to this directory. For me, it was easiest to just give the apache user ownership of that sub-folder.

Next, you’ll need to configure this folder as a DAV enabled folder. You’ll do this by adding a section such as this to your httpd.conf file:


<Location "bookmarks">
DAV on
AuthType Basic
AuthName "WebDAV"
AuthUserFile conf/passwd
Require valid-user
</Location>

In the section above, DAV on tells HTTP that the web_dav_fs module will be enabled for this location. It also says that authorization will use basic HTTP authentication and to use the passwd file in /etc/httpd/conf/passwd (at least this is where I keep mine) for authorization. The last line is critical in that it tells Apache that a valid user is required to access this location. This keeps the wrong people from reading and overwriting your bookmarks.

The next step is to create the passwd file in your server’s configuration directory. Make sure the user the server is running as has access to the location of this file. I used htpasswd with the -c option so that it would create the file in the directory and encrypt it properly.

Now, you’re ready to go. Go in to Foxmarks and cancel out of the wizard (The Foxmarks menu is in the Bookmarks menu if you’re unable to find it). Set the username and password for the user you are going to use to access the bookmarks. Then go to the other menu and put your server name or IP address in the server field. Next, the path should be the location you set above in the Location field. I went ahead and put my username after the bookmarks directory so that I could patition them out via users if I ever give friends the opportunity to store their bookmarks on my server.

To test it, just click the Maintenance section’s, “Upload Now” button. If you get an error message then check the Apache server’s error log file. That’s configured in your httpd.conf file. If it says password mismatched make sure you have the ability to read the password file you specified. If your password file isn’t where you says it is the Apache error log will tell you that specifically.

I did encounter a synchronization error after trying it out between two servers and this is known error that you can read about here: http://www.foxcloud.com/wiki/Foxmarks:_Error:_Precondition_Failed. There is a procedure at the bottom of this page that discusses a setting you can set in Firefox’s configuration (in the address bar type about:config) that will make this a non-issue. Read the limitations in the documentation, however. Once I had set that property I had no problems synchronizing between my two machines. If you don’t feel like synchronizing you can also just always upload download bookmarks.

I think that should just about do it. Drop me an e-mail or leave a comment if you have problems and I’ll try to do what I can to help.

Mock Objects – How Useful?

I have a feeling the title of this post will probably have people thinking I’m going to bash on the concept of them and that’s not really the case but at the same time I think their usefulness tends to be limited to a relatively narrow set of cases.

Where I Have Used Them

Not in as many places as I thought I would. The main area I’m using mock objects (and by the way, I’m using EasyMock 2.0) is in my code that tests some filters that are based on Spring’s OncePerRequestFilter. It makes it easier to test the code when I mock the HttpServletRequest, HttpServletResponse, ServletContext and FilterConfig interfaces. I provide the data that the Spring filter requires and provides during its interaction with these interfaces based on the particular test details. For example, I’ll tell the ServletRequest mock to expect a call to getServletPath and then give it the response as well as setting the run once attribute setting. I’ll also set some items on the FilterConfig that the filter will need. The filter also needs to set an attribute on the request as well.

The reason that mocks come in handy here is that I don’t have to create dummy implementations of these larger interfaces just for testing purposes. Also, the interaction with these interfaces I mock is pretty simple. So basically, they’re great when you have code that interacts with large interfaces but where the interaction is generally limited. More complex interactions would make the mocks, and hence the tests, much more brittle.

Mocks in general work pretty well as long as you’re using interfaces. Easy mock has some features for mocking concrete classes but I haven’t used that feature so I can’t comment on it. They also have some strong limitations, IMHO, that I think should be aware of before going too far with them.

Why Don’t I Use Them More?

There are a number of reasons, but the first that always gets me is I don’t always know how code is going to call the interface if some of my code relies on code I didn’t write or maintain. It means I have a lot of iterations through test cycles before I know how to fully script the mock. Sure I could read through the code but that’s an even bigger pain than the approach I take (at least to me it is). Take my prior example for instance. I had to give the mock to the filter and see where it failed first. If the first call it makes is to the FilterConfig then that will fail. Then it gets past that and I see it fails when it asks for an attribute in the request. And this continues on until I get it right. But that part that gets me is that I’m trying to test my filter, which in this case is a redirect filter, but I’m really doing a lot of work just to get the code I rely to get to the point where I can test my redirect filter’s capabilities. What happens if they make subtle changes in their code but the external functionality no longer changes. My tests break without functionality actually breaking because the use of the interfaces that are mocked no longer respond as they should.

To be fair, if I had created dummy implementations of those interfaces they might not fare a whole lot better since methods I don’t think are going to be called will probably cause the test to fail later on as well. Maybe for common interfaces such as the ones I use above it would be handy to have an implementation that I could easily instantiate that is built for testing interaction with the interface. In general, using code that you didn’t write and then having to test your code on top of that code, will probably be a pain no matter what.

Another reason I don’t use mocks as much as I originally expected to is because in general most of my services are built with testability in mind so I don’t need to mock up a lot of interfaces to test them. I can feed them data and they just work with the test data. Mocks tend to work best in cases where I have to deal with external systems more than anything and there aren’t suitable classes available that take the necessary test data for the code to function the way I need it to for my tests. Overall, I’d really rather have my unit tests run through real code where possible vs. mocks because then I know the interaction works where as a mock could provide a disconnect with the real system in some cases.

I suppose I’m lucky that with my personal projects I have the luxury of building code for testability in the first place so I don’t have cases where I have no choice but to mock up a more complicated interface. In my work projects most of my code deals with code generation and persistence so mocks really aren’t all that necessary for my work. How are you using mocks? Are there scenarios I don’t have to deal with that you’ve come across and where they’ve really simplified your testing life?

Enabling Google Analytics

I got my invitation code for Google analytics this morning and enabled it. It’ll be interesting to see how it compares to aw-stats reports and which seem more relevant or useful. Although, so far the cluster maps graphic that is down the right side of the side bar on this page is the most fun one in that I can see where people are visiting my site from quickly and easily. Lots of North American and European visitors and even a few from Africa, South America and so on. I imagine that most are coming in for my Java related postings.