comments edit

I just read Bruce Eckel’s blog entry about embedding unit tests in code. Ideally, he’d like compiler support in programming languages for unit tests.

The resulting syntax produced what seems like an obvious Java solution for the same problem: embed the essence of the unit test code within inline comments in the code for the class to be tested, and then automatically generate the JUnit code - which can then be used without any examination or intervention on the part of the programmer. To make changes, the programmer only needs to change the commented source code, and run the JUnit generator again.

It’s an intriguing idea and what I like about it is that these embedded tests have access to test code that you can’t otherwise test with an NUnit or JUnit framework such as private member variables and local variables within a method. It allows for very tight testing. Additionally, it places the test code as close to the source code as possible, directly embedded alongside of it. Perhaps a compiler with the highest warning level set would run all the tests and break if a test fails.

There are two things that make me wary of this approach. One, I feel it could muddy up the code a bit. Maybe this is just me being resistant to change, but I like the fact that all my test code is in a separate class library (but part of my solution). When reading the main code, it’s just the main code. I don’t have to wade through lines and lines of test code (which can easily include many more lines than the code being tested).

The second issue is that unit tests are superb for testing how well factored your classes are. When you write unit tests such that they are another client of your code (without access to your classes’ internals), it helps uncover usability issues with your code. If you find that you need access to private members in order to fully test your code, more times than not, it is a sign that your code needs to be refactored. I have no problems with refactoring code to make it easier to test because as I said earlier, unit tests are just another client to your code. If it’s easier to unit test, it’s probably easier to use for other clients.

Having said that, I realize that having compiler support for unit tests won’t necessarily stop anyone from writing unit tests as a client. In fact, it’s probably still a good idea despite my two issues with it. However, I’m not convinced it would lead to much better testing unless it was used sparingly.

comments edit

Found this on Slashdot. I already am a big fan of Sake, but who knew it was so versatile?

geeber writes “And you thought Sake was only good with Sushi? Well, think again! IEEE Spectrum has an article on how JVC has used sake to enable making speaker …

[Via Slashdot]

comments edit

Looks like a another company has stolen some of the thunder from Google’s announcement offering 1GB of email. Spymac announces in this post that they offer 1GB of email storage with a promise that there will be no adwords or other forms of promotion linked to email content.

comments edit

If you haven’t tried it yet, you should really give Froogle a look. I’m currently looking to buy an LCD monitor and I checked the usual suspects, Pcworld and Tomshardware for reviews, Pricegrabber for prices, but due to lack of inertia, I never thought to try Froogle.

Searching Froogle, I found a Dell Ultrasharp 17” (highest rated by PCWorld) for $399.00 with free shipping. At that price, I think I’ll get two. I was intending to get a 19”, but since 17” give you the same resolution as a 19” and are much cheaper, I think two 17” beat one 19” in terms of value and productivity.

I’m also in the market for an ergonomic chair, but that could take a lot of research.

comments edit

Now I’m every bit as much the bleeding heart liberal as the guy to my left, but I have to say that I believe the outcry against offshoring and outsourcing is purely a reactionary response to the current bad economy. I don’t believe that opposition to outsourcing is not based in sound economic principal nor is good for the country in the long run.

This coming from a software developer who makes his livelihood on custom software development. However, as jobs start to get created again (they will) I think the furor will die down a bit because everyone will be too busy working.

In the meanwhile, read this article I found from my economist friend Michael Krimm’s favorite magazine. He will be quite proud of me.

comments edit

Adam Kinney posts about finding Google phrases that return your site at #1 with more than 100 results.

Because we geeks have nothing better to do and have a deep seated need for the validation that only Google can provide, I checked my referrer logs and came up with the following three phrases.

Also, before you mistakenly read the third option, it’s spelled with an “A” not an “E”. It’s a skit on Dave Chappelle’s (a hilarious comedian) show about a white “Harriet and Ozzie” family in the 50s with an unfortunate last name.

Google ego boosting challenge #2, find a search phrase on that brings up your picture. A bit tougher…

comments edit

Spam For the past few months I’ve been teaching myself Longhorn programming via the PDC bits by building a better Spam filter. Some of the best filters will typically use an approach based on Bayesian probability modeling. For example, in this article Paul Graham discusses an improved algorithm for filtering spam

Although I am currently a software engineer (and manager) by trade, my background is in Mathematics and I’m not entirely satisfied with the current crop of spam filters. I realized that mathematical analysis alone isn’t enough. There has to be an “intelligence” factor.

The app I’m working on takes the Bayesian approach, but integrates that with intelligent filtering by taking advantage of the cheap cost of outsourcing and the proliferation of peer-to-peer software (made easier by Indigo I might add). You can see my new spam filter here.

comments edit

I’m looking to host my site and I’m ready to pay money!!! Does anyone have any recommendations? Right now, my top choices are WebHost4Life which has unlimited bandwidth, $9.95 a month, 150 MB disk space and 150 MB SQL Server space, with a $19.95 setup fee.

A cheaper option is with no setup fee, $9.95 a month, and 500 MB disk space, but only 10GB of monthly transfer. I think 10GB should be more than enough, but I’ve never heard of this company before.

comments edit

GAKEvery time someone tells me to register a component in the GAC, I think of GAK. Do you remember GAK? It was this Are you sure an alien didn’t sneeze this up? brightly colored gooey junk made by Nickelodeon. You can still buy the stuff!.

But what’s better than buying stuff? Making it! I found this little article online on how to make GAK. Your assignment, make tons and tons of this stuff! It never lived up to its potential to take over the world.

comments edit

I’ve been on a real Anthony Pappa kick lately. Right now I’m listening to Resolution CD 2 Track 12, “Solstice” at home and am blown away at how rich and full it sounds on my piddly Altec Lansing computer speakers. I spend way too much listening to my music turned down real low at work that I don’t appreciate how good this stuff can sound in the a half way decent environment.

Of course, I’d love to hear this in a PROPER environment. I need to look into getting a real sound system. My father-in-law is a Sony manager/engineer in Japan who is really into his sound equipment. He custom built his current speakers and they deliver a very smooth crisp sound. Hopefully I’ll be able to enlist his help one day in building a hi-fidelity system. He’s turned me onto Bossa Nova and Samba music.

comments edit

Poker ChipsRory at has an interesting proposition for would-be Computer Science mentors. Basically, he’s willing to pay for one-on-one tutoring in CS concepts over the web.

It’s an interesting idea if it works. In fact, it inspires me because I could use some tutoring myself, though my goal is not as lofty. Are there any experts out there at Poker, specifically Texas Hold’em?

I lost a wee bit o’ money this weekend and could use a refresher on how to play well. ;)

comments edit

I just realized that I haven’t been to in a very long time. Maybe months. Oh, don’t get me wrong, I’ve used Google plenty, but now with the IE Google bar and the Desktop Google bar, I have very few reasons to actually go to the Google front page. My view of Google lately has been search results.

So today, I decided to visit the Google front page for old time sakes now that they’ve totally revamped their look. Ok, so it’s about as noticeable as the difference between Old Coke and New Coke, but it is noticeable. I like it.

comments edit

I tried a new drink this weekend. It’s called an Irish Car Bomb. It’s a half glass of Guiness with a shot of Baileys and Irish Whiskey in a shot glass on the side. You take the shot glass, drop it in the Guinness, and then quickly down the whole concoction before it coagulates.

It almost has slight chocolatey taste and is very creamy and smooth. It was a nice alcoholic explosion before seeing Margaret Cho in concert.

comments edit

According to this article, Steven Hawking’s wife has been questioned by British detectives over claims that she has been assaulting the brainy cosmologist (no, a cosmologist is not someone who writes for Cosmo).

If she is guilty, Boo hiss hiss! This is no way to treat the most famous physicist since Einstein!

In support and honor of Mr. Hawking, I will bring back a long lost site from the archive and link you to MC Hawking’s Crib where you can hear him bust a rap in a imploding quasar’s ass.

code comments edit

Found this interesting post via Eric Gunnerson’s blog (PM for the C# compliler team) blog.

using (TimedLock.Lock(obj)) {
  // Do stuf within the lock

It’s an interesting approach to get a lock statement with a time out. It would be nice to perhaps add a timeout syntax to the lock statement in C#. Maybe it would look like this:

object obj = new object();
int milliseconds = 10000;
    lock(obj, milliseconds)
    	//Do something with obj
catch(LockTimeOutException exception)
  //Handle exception

One thought I had, and let me know if I’m off base, but it seems we could add debug code to Ian Griffith’s TimedLock class to “register” locks on an object. This would only happen if you conditionally compiled with #DEBUG, but the idea is that when a class gets a TimedLock on an object, TimedLock would add information (such as the call stack and thread id) to a hashtable with the object as a key. Thus, if another class attempts to get a lock on the object and times out, the exception could have information about who had a lock on the object. May be useful for debugging deadlock situations.

Ian Griffiths comes up with an interesting way to use IDisposable and the “using“ statement to get a very of lock with timeout.

I like the approach, but there are two ways to improve it:

​1) Define TimedLock as a struct instead of a class, so that there’s no heap allocation involved.

​2) Implement Dispose() with a public implementation rather than a private one. If that’s the case, the compiler will call Dispose() directly, otherwise it will box to the IDisposable interface before calling Dispose().

UPDATE: I implemented the stack traces retrieval. Check out my TimedLock repository for the code and history of this class.

comments edit

Don’t you hate it when you momentarily lose all control and pig out like a death row inmate on his last meal? I need to exhibit more self control during those “all you can eat” moments, because I am so uncomfortable right now.

This must be how it feels to be a 10 ton elephant trying to sit comfortably in an oh-so-NOT-ergonomic chair. I hear elephants complain about that all the time.

I know you want to hear all about my troubles, but I just needed to vent.

personal comments edit

How quickly would the pledge be altered if it ended “one nation under Allah” or “one nation under Buddah”?

AP - Not long after the Supreme Court came to order Wednesday with the invocation, “God save the United States and this honorable court,” the justices were deep in a wrenching argument over whether millions of public schoolchildren may continue pledging allegiance to one nation “under God.”

[Via Yahoo! News - Top Stories]