Tags

Have you ever been trying to solve a problem for a long time only to realize that you made a simple mistake? Did it make you feel dumb? Well I have and I have a feeling that I am not alone. At least I hope I am not. Here is just the latest chapter of this sad story.

I have been working on a Windows Phone 7 application. For those of you who aren’t familiar with the Windows Phone 7 development platform, it is based on a version of Microsoft Silverlight. Silverlight’s UI design allows the developer to make use of data binding. The UI design is built so that it can have two way data binding. So if the UI element changes then its data bound entity is updated and if the data bound entity is updated the UI element is updated. In order for your data bound entity to work like this it must implement the INotifyPropertyChanged interface.

In my Windows Phone 7 application I use a list box to display a list of entities. In this case the entity is using two way data binding. When you select an entity from the list box, a screen pops up allowing you to edit the properties of that entity. When you are done editing the entity, the application shows the list of entities again.

When I went to test the application, I selected my entity from the list, made a change to the entity and then saved the changes. Since I “knew for sure” that I was implementing the INotifyPropertyChanged interface in the data bound entity I expected to see the list of entities reflecting the changes I made when I edited one of the entities. Sadly it did not reflect my changes. Now of course you are saying to yourself given the understanding of the requirement to implement the INotifyPropertyChanged interface on the data bound entity, it seems likely that I did not do this and probably would have been the first place to look for a solution to my problem.

Well, this did not occur to me at the time because as I mentioned before “I knew for sure” I had implemented the INotifyPropertyChanged interface. I went through the process of what I thought could be wrong. I made several changes to the logic around the UI. I made changes to the UI itself. I even opened up the source code for the controls I was using. At this point I was willing to blame everyone anything except the simple answer. After 5 hours, yes 5 hours, of debugging and wasting time, I decided to move on and start working on another part of the project. While working on the other part of the project, I needed to make a change to the data bound entity I was using earlier. It was then that I noticed, and then gasped, and then cussed, and then called myself an idiot, and then laughed.

You see I had been so confident that I had implemented the INotifyPropertyChanged interface on the data bound entity that I never even verified that I did implement it. Only through coincidence did I realize that in fact I was to blame. I had not implemented the INotifyPropertyChanged interface. I did not check the most obvious thing that could have been wrong. It cost me almost an entire day’s worth of work. So naturally I started to wonder, how could I have of avoided feeling dumb?

Tips on Avoiding Feeling Dumb

These are the tips I came up with:

Never Assume. You know what it makes you! Don’t assume you did something unless you can prove it.
When something isn’t working don’t rush your thoughts. Take a deep breath then think through the problem.
Break down the problem by breaking it down into simpler parts.
Spend some time away from the project. This will allow you to clear your mind. There have been many times after spending hours trying to solve a problem all day, and then the next morning I solve it in 5 minutes.
What process do you go through to solve a problem? What tips do you have? Let me know. Please leave a comment.