Wednesday, February 20, 2008

Interfacing Hardware with .NET

I went to my local .NET user group meeting last night and watched a very exciting presentation by Brian Peek on interfacing hardware with .NET. The presentation focused around the use of Phidgets USB controller boards to read and control various inputs and outputs. Phidgets has the controller boards as well as a whole host of input devices themselves for factors such as RFID scanning, temperature, position/rotation, and light. They also have some small servo motors. To round it all out, they provide APIs for .NET, Visual Basic, VBA, LabView, Java, Delphi, C and C++. The examples Brian showed us looked ridiculously simple to program with the API they provide. It certainly puts a new spin on the various ideas I've had over the years for doing home automation.

The last part of Brian's presentation was about interfacing with the Wiimote from .NET using the WiimoteLib managed library he developed. He put everything together and showed us a simple R/C car controlled by a Phidgets digital i/o board using the Wiimote as the remote control. It was the first time I'd ever seen a .NET user group so enthralled.

Tuesday, February 19, 2008

Lingering check-outs: Increasing VS Build Stability

For those of you who use the checkout-modify-checkin method of source code control within Visual Studio (I.e. many Visual Source Safe users) here's some advise to increasing integration ease and build stability between developers and a build system.

As you start to share more VS projects, it's important to be aware of what you have checked out, particularly the project files. When adding items, if you check in the project file, but not the new item itself, the project will not build because of the missing item in source control. However, if you leave the project file checked out while you work on the new item, another developer won't be able to checkout the project to modify it or add items to it because of your exclusive checkout. What will often happen is that one developer is in the process of building the new item when someone else needs to work with the project. So the first developer checks in both the project and the new item. However, the other developer still can't build the project due to the half finished item. This leads to wasted time while the unfinished, breaking code is commented out and checked in. This results in confusing noise in source file history.

The best way of avoiding this scenario is to keep project files checked in as much as possible. My experience has shown the following process for adding items to projects to be most affective:

- Let Visual Studio check out the project when adding the new item.
- Immediately check in the project and new item as it was added. Generally a build test isn't necessary on new items because they are void of non-compiling code. (Continuous Integration can help ensure this even if your local build doesn't work due to other changes you are making.)
- Proceed to edit the new item which will need to be checked back out.

By using this procedure the project file gets checked in and the new (empty) item is added to source control resulting in a successful build. Now when another developer needs to modify the project or add an item to it, they'll get the updated project as well as the empty item which will compile. They can then keep working without compile problems.

Here are a few other things I've found to help:
- If you don't already, try using Visual Studio's Pending Checkins toolbox window so you can easily see what is checked out to you within the solution. It's much easier than searching thru the solution explorer or using VSS explorer. Using this reduces the likelihood of forgetting to check in a file.
- Don't let Visual Studio automatically check out files. You'll be much more likely to remember that you need to check files in if you were forced to acknowledge their checkout.

I realize that another solution to this problem is to use the modify-merge-commit method. However, the fact is that many development teams use Visual Source Safe, and VSS doesn't have the best merge tools so the exclusive checkout method is preferred for it's stability.

Even working on aggressive projects with many developers working in the same projects, I've found that 2 developers are rarely working in the same exact file(s). Using this technique to maintain the project integrity goes a long way to reducing interference between developers.

Tuesday, February 12, 2008

Enlightening Insomnia

It's rather interesting that so much mental stimulation can come out of insomnia.

I recently had a side job doing technical editing for a technology book. It involved lots of reading. My wife works evenings and we have a toddler so my time after work is consumed by him so I wasn't able to do much work on my reviewing until after 8 pm most nights. As a result I struggled to finish the evening's block of work to me nightly fatigue. However, after I finished, I'd check email and get distracted by something that would lead to continually cascading diversions until before I knew it, the little hand on the clock had worked it's way past 1. There I'd be more awake then when I put my son to bed almost 5 hours prior. Of course, the very fact I stayed up too late would be the source of the next evening's difficulties. Oh the vicious cycle.

At the moment it's almost 3:30 AM. I went to bed early quite tired and with a headache. I think I slept for a few hours, then awoke for my nightly fight with the cat over my claim of the bed. This was followed by an hour+ of tossing and turning as I thought about work and side projects, other miscellaneous distractions and my resurfacing headache. After a while I gave up, took some pills and came to the computer. I have since spent about 30 seconds checking email and several hours writing blog posts and looking up random word definitions on google.

I wish I had a hibernate button.

Developers today: Learning to fish

I have been a member of the Wrox programmer to programmer (p2p) forum for many years now. When I first joined it, the forum was a standard mailing list community populated by a real good bunch of folks including some Wrox authors themselves. I recall most of the questions to be fairly thought out and asked by people who had run out of options trying to solve their problems. I started as a new developer learning classic ASP. I had books, I read them. I tried code examples and experimented with new things in an effort to understand how things worked and to educate myself so I could do my job. But when I hit a brick wall or just wanted to understand why some code behaved the way it did I would email the list. I got a lot of great help there and subsequently met a good friend through the list. I owe much of my initial education in web and ASP development to the books and that list.

In part due to a feeling of obligation to give back to the digital community that helped me and simply because I like to educate people by sharing my experience, today my participation on the forum is that of a contributor instead of an inquisitor. I enjoy helping people learn and understand that which I can explain. Even when a question is asked about a topic I might be unfamiliar with I think about a solution and try to provide suggestions, even if they are only abstract, conceptual ideas. Often I become intrigued with the question and stop what I'm working on, to the detriment of my own productivity, and try to solve it myself in an effort to quench my own curiosity. Never have I done so without learning something new.

This nature of mine is what makes me a successful software developer and is, I believe, a trait necessary to those that are in the same profession. I enjoy solving problems and exploring the technologies I use to find better and faster ways to solve those problems. Most often I find a problem I am having has already been had by others and that there are solutions available within a short distance of a thoughtful search.

Getting the Fish
It seems that more and more people pursuing software development lack the natural tendency to solve problems. I am finding that an increasing number of participants on the p2p forum are looking only for the answer to today's riddle and not an explanation of the underlying problem. They want sample code or in many cases, they just want someone to do it for them. In extreme cases a post contains what suspiciously looks like a homework assignment with the query "answer these questions", without so much as a "please". I highly doubt the poster is providing a "quiz of the day" to help us keep our minds sharp".

In the cases of an inquiry for an explicit answer, most often a few seconds of searching will reveal countless pages of sample code or reference documentation relating to the problem at hand. It baffles me to think that someone likely spent more time writing a forum post than it would have taken to search and find the answer. This is evident by the number of responses on the forum that are simply links to other forum threads, articles, tutorials, documentation or simply a google search with the keywords of the original post topic. Smart contributors aren't likely to spend their time regurgitating available information.

Learning to Fish
I hesitate to provide discreet answers to questions that I know a poster should be able to solve on their own. Often I'll reply with a question to which the answer should reveal the solution. I want to help people learn to think about the problem or how to solve it instead of just providing them the answer.

A short post that simply says "here's my code, please fix it" (which I could easily do so) is less likely to get a response from me than one that has been well thought out and takes longer to read. The former is simply a cop-out while the latter conveys the poster's interest in understanding the problem. It is surprisingly easy to spot posters who are genuinely stuck and are just missing something tricky that I've encountered before. The answer is easy to provide and an explanation gives the inquirer a tidbit of knowledge that is not so easy to find. Any case where the explanation is far more valuable than the answer itself is much more enticing to reply to with the goal, of course, being that the person asking will obtain some knowledge that will help them in the future to solve similar problems.

The inherent nature of problem solving seems to be missing in more and more people. I suppose this observation is simply influenced by the effects of the nature itself. People who know how to solve problems are not the ones asking for discreet answers. They are finding answers on their own. However, I refuse to believe that they are absent altogether. I often find a solution to a problem I'm facing, but still don't understand why the solution works, or why the problem exists in the first place. Most of my own inquiries on the forum are explanations of the problem I had, the solution I found and the question of whether others have encountered this and why it works the way it does. These posts are quests for further knowledge of the question and answer, not the answer itself. Unfortunately, these questions often go unanswered. Occasionally they spark very stimulating conversation that, while not necessarily answering the question, forces further exploration of the problem. These are my favorite threads.

Availability of fish
Analogous to a grocery store, the internet is a grand marketplace of food for the knowledge appetite. Are people becoming less capable of solving problems due to the access to answers? Is this eliminating the need to know how to the grow knowledge and solve problems? Have people become complacent or simply lazy by the prospect that answers are out there and they need not know themselves how to solve them? I hope not. My goal is to help people understand the why and the how and not just find the what.