Where Are The Wise Men?

Mike's Ramblings

Large Datasets in a Unit Test

| Comments

I spent my whole day essentially working on one unit test.

Yes, just one unit test. But let me explain.

This part of the app just does something very simple -- serializes the results of a database query into XML. Of course, it's not "simple" but we have tools to make this simple. You take some Spring and you mix in a little [JiBX][]and they do the work. You just have to use them.

To test this, I mocked up a small dataset and used that to get the XML. I could manually check those values and it was fine. But the query won't return a small amount of data -- it will be large. At least a couple hundred items.

You could say, "Well, if it works on a small set, then it will work fine on a large one." And, really, you are probably right. But how do you know? And how do you make sure? Since we are usually going to have a few hundred items to serialize, shouldn't we put that into our tests? Why, yes.

some mock data to load into the test. Getting the base was easy -- I just took a snapshot of some query results and made that into the XML file. I would then deserialize the XML file into a DOM that should be the same DOM as the mock data (with JiBX, [it becomes trivial to marshal and unmarshal objects into XML][]).

But how to get the XML object? I started by writing a Python script to read the XML and put that into a snippet of Java. To the people who don't use scripting and/or dynamic languages this may seem strange. To me, this is natural -- Python is much better at handling text and (IMHO) better at dealing with XML.

As I studied the resulting Java, I knew that I didn't want to put that into a Java class. It was too hard to change! I didn't want to run the script, put it into the Java class, massage it so it compiles, and then test. So I thought a while and then remembered I could to all this in Spring! I could take the XML and simply put into a Spring config, populating my data. Then, in my unit test, I could called the applicationContext
to get the object.

So I changed my Python script create an Spring config bean instead of a Java snippet. I put it into it's own config, that I only call in my unit test. I named it mockdata.xml.

And, you know, it worked like a charm.

This shouldn't have taken me all day, but it did. I spent too much time in the Java snippet instead of letting Spring to all the work for me. But, with the Python script, I have a re-usable solution so when the data needs to change, I can easily re-do my tests.

Testing should not only be fun, but correct as well.

Powered by [ScribeFire][].

Too Busy At Work?

| Comments

We had another Faith and Work lunch today. The topic was "Are We Working Too Much?" We were given an article that refuted the claim that we work too much and gave some good evidence to the contrary. But the article was written in 1993 and work has changed a lot since then -- we now have Blackberries and remote desktop so we can work anywhere.

One thing that I thought of that I didn't mention is that it isn't just work. It's church, it's school events, it's sports practice, it's music lessons, etc. None of those are bad by themselves, but we can't do all of them. In fact, we have to work harder to get more money to afford to do more things, yet we have less time to do them.

How does that madness end?

Powered by [ScribeFire][].

Getting Closer to the Perfect Work Environment

| Comments

I had a co-worker peek over my shoulder the other day and said, "Are you connected to a Unix machine?"

"No, that's just [Cygwin][]." And I explained to him what Cygwin was.

He laughed. "Most people want Unix to be more like Windows. You want Windows to be more like Unix."

If course I do! My perfect world would have me working on a Linux desktop but, since that isn't going to happen, I'll use Cygwin as much as I can. And lately I have found out that I can really take it to the next level.

I finally figured out how to get around our Firewall-of-Doom to update Cygwin (since we can update Eclipse online, I figured I can update Cygwin as well). In the latest version, I noticed that [GNU Screen][] was on the list. Was that true? If so, my year was made.

So I did the update and then [zsh started flaking out on me.][] That was bad. Really bad. But it got fixed this morning (simply doing "rm ~/.zcompdump" and "compinit" did the trick). Then I installed Screen. Unlike what most people use Screen for, I'm simply happy that I can have multiple prompts and access them without touching the mouse. The copy-and-paste and scrolling options are just gravy.

I got Screen running and then installed [rxvt][]and started using that instead of Ponderosa or Console2. I remember having problems with output from "normal" Windows processes on it (like Java!) but I haven't seen any yet.

How geeky is all of this? Very. But it's all to make Windows more and more usable to me -- by making it more and more like Unix

Powered by [ScribeFire][].

Goodbye, Madeline L'Engle

| Comments

Madeline L'Engle, who I consider one of the best children's authors of all-time, passed away on Thursday. NY Times Article is here

I read _A Wrinkle In Time_ in elementary school and loved it. A complex story of high imagination. Later, in my adult life, I purchased all the books in the _Wrinkle_ series. Just a month ago I read _A Swiftly Tilted Planet_ and was captivated by the complex yet simple story.

Her theology was a bit unorthodox for some, but I always enjoyed the fact that she put a lot of her faith in her books. God was always present, Jesus was always mentioned, and it was always Good vs Evil. Not all that can be said about Harry Potter.

I think L'Engle is better than JK Rowling. If the ending of Harry Potter has got you down, I would suggest staring with _A Wrinkle in Time_ and/or _Meet the Austins_.

Custom Service? Or Counter Rudeness?

| Comments

I had to mail a package at the post office today. That isn't a huge deal -- there is a postal center about two blocks from work. But I've never been there, but only heard about it.

I heard they were rude. Yes, I know, the thought of U.S. Postal Workers as being rude isn't that difficult to imagine. But I have heard extreme things about this place.

But I walked in and there was only one gal working at the counter. I said, "I need to get postage on these?"

"You want express, priority, or first class?" She said it in a tone that said, "Why are you bothering me?"

I said, "Whatever is cheapest."

She gave me a list of prices, whether I wanted insurance on it, etc. Nothing too out of the ordinary. Until she said; "I hope you don't mind me telling you this, but your penmanship is horrible."

Now, I know that I have horrible handwriting. I've had horrible handwriting my whole life. Teachers tried in vain to get it something that resembled English but they always gave up in utter frustration. So, really, it's like telling me I'm male. Yes, I know, but does it really matter?

I was a little dumbfounded and then she started talking about how she dated a guy with bad handwriting, etc. etc. I wished her a good day and left.

But I left my horrible penmanship there.

Powered by [ScribeFire][].