code comments suggest edit

You’ve probably heard the term Impedance Mismatch thrown around when discussing object relational mapping. I’m sure it comes up every morning at the water cooler. Maybe you’ve even thrown it around yoursef a few times. Do you know what the term means?

Object relational mapping refers to the process of mapping your relational data model to your object model. Object Spaces is a highly publicized framework for doing just that. The mismatch I refer to is a result of the differences in structure between a normalized relational database and a typical object oriented class hierarchy. One might say Databases are from Mars and Objects are from Venus. Databases do not map naturally to object models. It’s alot like trying to push the north poles of two magnets together.

Interestingly enough, the term “Impedance”, now bandied about in software engineering circles, is borrowed from electronics. I’m going to do a disservice to electrical engineers all over the world by offering a very simple explanation. (My aplogies to you EEs out there).

Impedance is the measure of the amount that some object impedes (or obstructs) the flow of a current. Impedance might refer to resistance, reactance, or some complex combination of the two.

Perhaps an example is in order to illustrate impedance mismatching:

Imagine you have a low current flashlight that normally uses AAA batteries. Don’t try this at home, but suppose you could attach your car battery to the flashlight. The low current flashlight will pitifully output a fraction of the light energy that the high current battery is capable of producing. Likewise, if you attached the AAA batteries to Batman’s spotlight, you’ll also get low output. However, match the AAA batteries to the flashlight and they will run with maximum efficiency.

So taking this discussion back to software engineering, if you imagine the flow of data to be analogous to a current, then the impedance of a relational data model is not matched with the impedance of an object hierarchy. Therefore, the data will not flow with maximum efficiency, a result of the impedance mismatch.

comments suggest edit

Quick! What is the definition of the word moot? I’ll use it in a sentence.

Upon reflection, Hezekiah realized that Ezekiel’s argument was a moot point.

If you said something along the lines of “irrelevant”, then you’re wrong. Or perhaps, right. You see, moot is one of those strange words that can be self contradictory. Originally, moot started off as a noun. It was a legal term for a hypothetical case argued by law students. Sometime around the mid 16th century, it changed affiliations and became more commonly used as an adjective.

Thus, in my example above, Hezekiah believes in his heart that Ezekiel’s argument is worthy of debate. However, around the 19th century, people started to use the word to mean “of no particular significance or relevance”, which is the typical usage today. How confusing is that for the foreigner who looks up the word in the dictionary and finds both definitions? Context is everything. Perhaps we can submit the english language to ECMA for standardization.

comments suggest edit

Sequoia National ParkWe’ll be out enjoying the wilderness this weekend at Sequoia National Park. I once worked at a company with Sequoia in its name. This park is not owned by them.

code, personal, tech comments suggest edit

UPDATE: I finally followed up with part 2, only 8 years later.

Typist In PainWhen you ask the average programmer what problems plague the practice of building software, you’ll probably hear responses such as:

The impedance mismatch between relational databases and object oriented code.

The difficulty of writing secure code.

Managing complexity and requirement changes..

Certainly, these are all worthy problems to tackle, but the problem that comes to my mind is how much pain I’m in when I write code and how few people really understand this. I hope to write a series of articles about typing pain and what to do about it based on my experience and research.

If you sit in front of the computer 8 or more hours a day, you’ve probably experienced pain at one point or another in your hands, wrists, shoulders, and/or back. Typically, if you’re like me, you’ll ignore it at first, maybe blame yourself for being weak, try hitting the gym more. However, at one point or another, you have to deal with it because it gets too painful to ignore. Friends and coworkers may not understand, but if you dig around, you’re almost guaranteed to find one or more coworkers who are silently dealing with this type of injury.

And yes, I do mean injury. Everybody seems to want to call it Carpal Tunnel Syndrome (CTS), but CTS is only one small type of injury within a family of injuries often grouped under the term Repetitive Stress Injury (RSI). RSI ailments include tendinitis, neuritis, CTS, etc…

The real difficulty of these types of injuries is that they are a relative newcomer in the annals of medicine and are thus quite misunderstood. From outward appearances, you’re sitting on your ass all day, how can you get injured? Well let me give you some stats.

At the end of an average eight-hour workday, the fingers have walked 16 miles over the keys and have expended energy equal to the lifting of 1 1/4 tons. - DataHand

This rapid increase in RSIs coincides with the increase of personal computer use. There are now an estimated 70 million PCs in the USA. Dr. Pascarelli estimates that RSIs now cost companies $20 billion a year. - WebReference.com

Hopefully the first quote highlights just how much work we make our little fingers do in a day, and the second quote appeals to your (and your employer’s) pocketbook. Much of these costs can be easily reduced dramatically by taking a proactive and preventive approach to RSI. For the company, that means saving a lot of money by not taking a short-sighted approach. Make sure your employees have the right equipment and an ergonomic evaluation. For you the individual, that means making sure you work in an ergonomic fashion and get help at the first sign of pain.

I will talk a bit about my experience in upcoming postings. I continue to struggle with pain, but I currently have Workman’s Comp which pays for my treatments and hooked me up with an ergonomic chair.

Some references of note:

comments suggest edit

Be aware that there is a PayPal scam going around. I received the following email which had a forged from address of “DoNotReply@PayPal.com”. There’s a reason they don’t want you to reply, because it exposes the scam. They’d rather have you run the attached program. DO NOT DO IT! This is a scam. It is easy to forge the headers of an email. It didn’t come from PayPal.

Dear PayPal member,\ \ PayPal would like to inform you about some important information regarding your PayPal account. This account, which is associated with the email address\ \ phil@sequoiasoft.com\ \ will be expiring within five business days. We apologize for any inconvenience that this may cause, but this is occurring because all of our customers are required to update their account settings with their personal information.\ \ We are taking these actions because we are implementing a new security policy on our website to insure everyone’s absolute privacy. To avoid any interruption in PayPal services then you will need to run the application that we have sent with this email (see attachment) and follow the instructions. Please do not send your personal information through email, as it will not be as secure.\ \ IMPORTANT! If you do not update your information with our secure application within the next five business days then we will be forced to deactivate your account and you will not be able to use your PayPal account any longer. It is strongly recommended that you take a few minutes out of your busy day and complete this now.\ \ DO NOT REPLY TO THIS MESSAGE VIA EMAIL! This mail is sent by an automated message system and the reply will not be received.\ \ Thank you for using PayPal.\ \ uiaumzem

code, tdd comments suggest edit

Test First Development, the process of writing unit tests to test the code you are about to write, is one of my favorite software practices that has an impact on producing better written code. However, it’s no a panacea. It is true that I use the debugger much less often because of TDD, but there are still occasions where it’s important to manually step through code line by line.

Personally, I use NCover as my first line of defense. It highlights the lines of code that haven’t been executed by my unit tests. A lot of these turn out to be non-issues such as the last “}” in a method or an assertion that this line should never happen (for example in the default: section of a switch statement when I believe the default should never be reached).

There are those times, however, when you don’t have time to write a unit test to excercise a particular line of code. Stepping through it is a wise idea.

Also, unit tests won’t uncover errors of omission. Stepping through your code will often jog your memory and remind you that, Hey, I forgot to make the code jump rope here AND I forgot the jump rope test fixture.

comments suggest edit

Google Logo with Burning
Man

Sergey and Larry have moved up a couple of notches of coolness in my book. They’re burners! They attended Burning Man in the summer of 1999. The logo above is what they put on the Google site while they were out of town. In commemoration of the upcoming Burning Man, I’ll put up some picks later from 2002 when we went.

comments suggest edit

ThreadTypically when you spawn a new thread, you want to give it a name to facilitate debugging. For example:

using System.Threading; //.. other stuff.... Thread thread = new Thread(new ThreadStart(DoSomething); thread.Name = "DoingSomething"; threat.Start();

The code in the method DoSomething (not shown) will run on a thread named “DoingSomething.”

Now suppose you’re writing a socket server using the asynchronous programming model. You might write something that looks like the following:

using System.Net.Sockets; using System.Threading; ManualResetEvent allDone = new ManualResetEvent(false); public static void Main() {     Socket socket = new Socket(...); //you get the idea     while(true)     {         allDone.Reset();         socket.BeginAccept(new AsyncCallback(OnSocketAccept), socket);         allDone.WaitOne();     } } public void OnSocketAccept() {     Thread.CurrentThread.Name = "SocketAccepted";     allDone.Set();     // Some socket operation. }

In the example above, we’re setting up a socket to call the method OnSocketAccept asynchronously when a new connection occurs.

When you run this, it may work just fine for a while. It might even pass all your unit tests. Don’t you just feel all warm and fuzzy when the green bar appears? Put this in production, however, and that warm and fuzziness may turn into cold dread as you’re guaranteed to run into anInvalidOperationException.

Why is that? Underneath the hood, when the OnSocketAccept method is called, the CLR rips a thread from from the CLR’s thread pool. When the method completes, the thread happily returns to the pool to finish its Pina Colada. Eventually, that thread will resurface, and that’s where the problem arises.

You can change the name of a thread, but you can only change it once.If you try to change it again, you’re greeted with an InvalidOperationException. When a thread is returned to the thread pool, it holds onto its name. Its happy to have a sense of identity and will hold onto it even when it resurfaces to execute another method. To protect from this, always check the name of a thread before setting it like so:

if(Thread.CurrentThread.Name == null)     Thread.CurrentThread.Name = "MyNameIsBob";

Your threads will thank you for it.

comments suggest edit

This is one of the funniest tech support stories I’ve heard in a long time. Even you non-geeks can appreciate this…

We sold a computer to an elderly lady who took it home. We had tested it, and it worked great at the store. But, when she got it home, she could not get it to turn on. I work on the phone with her for an hour. \ \ “Is everything plugged into the power strip, maam?”\ “Yes, everything is.”\ \ So, I was sent to her home. Sure enough, everything was plugged into the power strip … including the power strip.

[Via The Daily WTF]

comments suggest edit

Guess he should have remembered to take out the trash… Oh wait, he tried.

WESTON, Conn. – Max Miesel didn’t get very far with his prom date – who’s a porn star. \ \ Max won a date with adult film actress Tyler Faith on Howard Stern’s show Friday. Max is a student at Connecticut’s Weston High School. The Advocate of Stamford, Conn., reported school officials and Max’s parents stepped in before Saturday’s prom…

[via http://www.channelcincinnati.com/education/3389768/detail.html]

comments suggest edit

Thanks to the help of the very talented Joel Bernarte, I have a nice new look to the site. He created the logo you see at top. I then spent a bunch of time trying to modify the layout and Css to do the logo justice.

If you’re viewing this in an aggregator, you’ll actually have to take a second outside of the aggregator to look at my site haacked.com using that antiquated piece of technology that used to rule your life called a Web Browser (which might just be integrated in your aggregator). Thanks. Now back to the new technology that’s ruling your life…

comments suggest edit

See, this is exactly the type of comment spam I’m hoping to avoid.

Harrrrrr… shoulder of pork and ham!!! $4 dollars at the quickie-mart! I am a prince from Niger, please give me the keys to your Mercedes Benz. I love men who aren’t afraid to blog!

Only in this case, I’m afraid I know this guy.

;)

By the way, the ASP.NET Resource Kit has a free version of the SAX human verification component. That ought to help combat automated spam.

comments suggest edit

Another option is to simply remove the web interface for comments and only allow comments via the Comment API.

I have a hunch that most of the comment spam comes from people who stumble on my site via the web. Most people who post via the CommentAPI are using an aggregator and are thus subscribed to my site, or were referred by another subscriber.

UPDATE: I may be confusing Comment Spam with Comment Graffiti. As far as I can tell, I do not have any comments from any automated sources, nor comments advertising products on my site. The “spam” I have seems to merely be comments by random people who occasionally write offensive comments.

comments suggest edit

In an email to Ian Griffiths I mentioned that I wished he had a comments section because some of his posts are so intriguing I have to reply. ;) His reply relayed a common angst regarding enabling comments on a blog, comment spam

Looking around, I see this is a common problem as evidenced by the following posts by Roy Osherove who wants to turn comments off, Chris Anderson who threatens to turn them off, and John Lam who did turn them off.

This is disheartening because comments can be a vital part of a blog encouraging lively and insightful conversation. But then again, not if your constantly getting these type of comments

Noticed on a dirty white van, letters made by hand: \ “I Wish My Wife Was As Dirty As This.” \ Underneath, different style: \ “She Is!”

Funny? Maybe. But off-topic. Unlike the garden variety email spam, the bulk of comment spam tends not to be automated. If it were, it’d be plenty easy to stop by requiring users to type in some text they see in an image.

Rather, much of the smelly meat is due to the fact Google is bringing droves and droves of visitors to blogs as bloggers all link to each other. Some of these unwashed masses decide to leave their mark on your site.

As John Lam pointed out, simple IP filtering isn’t enough. I’ve been thinking alot about how to leverage network effects to reduce comment spam. For example, in general I’ll trust people who have subscribed to my blog to make comments, and if they’ve been subscribed a while, I’ll trust those that subscribe to theirs.

I can imagine adding features to blogging back-ends such as .TEXT or DasBlog whereby trust relationships can be built by using something similar to the TrackBack API. Suppose I subscribe to your blog and you try to make a comment on my site. Since my blog knows that I am subscribed to yours (this will require aggregator integration), it automatically lets you comment. It then can go one step further. Perhaps it will ask you, “Any changes to your whitelist since we last exchanged data?”. We can then exchange whitelist info. Certain spam engines work in this manner.

The big problem with this approach is that identity is a tough nut to crack without requiring that commenters create a login and password and building in some sort of verification system.