September 9 2010




 
Search Blog Entries:



What is this?

Column Details
 
What makes coding hard?

Let me first state that I really like Visual Studio 2005 and that I am thrilled by the way it gets me more productive. However, last week I ran into a problem and I am trying to blame it on new features of Visual Studio 2005. I was working on a Windows Mobile 5.0 application that needs a data entry form that contains a large amount of data, more than can fit on the screen of a Pocket PC. At the same time I want to properly support different screen orientations as well. So here is what I did. I decided to create a Panel control on the form, docked the Panel control to fill the entire form and added my edit controls on it. I also made sure to set the AutoScroll property of the Label control to true, so I would not have to deal with scrolling myself. One of the nice features of a Windows Form application is letting the runtime deal with nasty details like scrolling for me. I ran into problems when I showed the SIP on the screen, because a part of my data entry screen was covered by the SIP. Of course, there was an easy solution for this. Simply resizing the Panel control would solve my problem. In fact, this is true and auto scrolling would make sure that every control on which data could be entered would be visible. Now this is where I ran into problems. I decided to use the Form Load event to resize the panel, taking the size of the SIP and subtracting that from the current Height of the Panel control. After adding this functionality I ran the application and I found out that I could not resize the Panel control. Instead of thinking I started debugging my code, and surely found out that it was not possible to resize the Panel control. Again, instead of thinking I started to look for different solutions, something that took me a couple of hours and I still did not have a good solution for my problem. Finally I started thinking and only then I realized that I had set my Panel control to dock to the full screen. Could it be that the Docking property overruled my attempt to resize the Panel control? A quick experiment showed that this indeed was the case. So here I was, wasting a few hours because I forgot to think. Now I am desperately trying to blame Visual Studio 2005 for this. After all, it generates so much code for me that I hardly have to think, or at least that is my excuse right now. Yes, I know this is not really fair. Why blame a development environment and hide behind excuses for not thinking myself? At the same time, this is a risk. With more powerful development environments it is tempting just auto generate lots of code, not thinking what you are really doing, and even in case of problems, trying alternative solutions instead of analyzing what is causing the problem. For the short term I have learned my lesson I guess. Make sure to keep on thinking and trying to understand situations with unexpected behavior. This one was not too difficult to solve but it was an expensive bug if I look back at the time it took me to solve it. From now on I will think again. I will be in charge, not some development environment. Auto generated code is great, saves time, but only if I keep on thinking. Sorry Visual Studio. You were not to blame. This was my fault.

 

Maarten Struys

 
Back








SpiralFX Technology Solutions
www.spiralfx.com


Do you want to learn developing a full blown Windows Mobile Application? This article and accompanying multimedia content will help you to do so. It will be extended over the upcoming weeks / months, so check back regularly.
 
Read Full Article