Archive for December, 2007

New Years Programming Resolutions

December 31st, 2007

After my last post about regular expressions, I received my order from Amazon. I have spent the weekend reading up on regular expressions and trying out the example in eGrep on my Mac and in Cygwin on my PC, and in C#. I have made a resolution to become proficient in regex this new year and am already making great progress.

The next resolution is to become a better Agile developer. I am a “card carrying” agile developer, but lately I have gotten in the habit of waiting a week or longer to check in code. I have been working on a lot of projects alone lately, and I need to quit letting that be a crutch. I resolve to start working on discreet functionality and checking it in as soon as it is completed and tested. Along these lines, I have gotten slack on my unit testing. No more, I tell you!

On top of all of this, I want to get some more Silverlight and ASP.Net time in this year. Silverlight is going to explode, and I want to be all over it.

The last point is that I want to keep blogging. To me, this blog keeps me honest in my programming goals.

Happy New Year!

Regular Expressions

December 26th, 2007

I have been a professional programmer for about ten years, which is to say someone has actually been paying me to write programming code since about 1997. In that time I have learned (or already learned previous to 97) the following languages, and used them in my professional endeavors: C, C++, Visual Basic, HTML, Javascript, PERL, SQL, Java, CSS, VBScript, ASP, VB.Net, C#, ASP.Net, C# 2.0, Windows Forms, Tcl, PL-SQL, .Net 3.0 (WPC, WCF and WF). I have also hobby programmed with a few languages during that time, like Ruby and Python. But in all that time, I have never really wrapped my head around regular expressions.

I don’t know what the deal is with me and regular expressions. I would estimate that, on average, I have found a problem that can easily be solved with regex about once a month throughout those ten years. There have probably been many more problems that I have solved in other ways the a regex could have solved, but I just did not recognize the fact at the time. No matter, I never seem to learn this powerful expression language.

When I do need a regular expression, I end up going out to Google and searching for it. This is pure lazy on my part. I don’t do this for SQL or C#! While I may look up references on functions or libraries, I usually try to thoroughly learn any language I am going to be using professionally.

I often end up at a site like RegExLib. I don’t know why I don’t just go to a site like this one and actually learn regular expressions inside and out. But I don’t.

Its not like I don’t have a basic clue about regular expressions. I have worked in VI (or VIM) and *Nix long enough to have a few expressions memorized. But still, every time I need something complicated, a searching I go!

Today I needed a regex to validate that a string is a valid file path in windows. It needs to not only be able to detect a valid local file path, but a valid UNC file path. I realize that I don’t really need to find one regex that will do both. I can use two regex expressions and embed them in an if/else if block in C#. The point is that I don’t know how to write either one of them, so I find myself searching the web for someone else to answer this problem.

I think I am going to make a resolution. The year 2008 will be the year that I finally become the master of regex!

UPDATE:  I found the answer for my regex problem in the form of one, neat little expression.  Afterwards I ordered a 5 Star reviewed book on Regular Expressions from Amazon.com.  I will review the book after I have dug into it.

Spell Check for VS 2005 and VS 2008

December 18th, 2007

I had a big WTF moment this morning.  Apparently there has been a spell checker add-in for Microsoft around for a while, because they just released version 2.0.  The Visual Studio Web Developer Team Blog documents the usage of the new spell checker.

You can download a VS 2005 Version or if you are already using VS 2008, you can download that version as well.

When I first tried installing, the install wizard asked if I wanted to install for “Just Me” or “Everyone”.  I picked “Everyone”, and it did not work.  After reading a few blog posts I tried the “Just Me” option (after uninstalling) and it works fine.

I can already see that I don’t like the fact that I cannot add items to a custom dictionary.  But all in all, it looks like a very useful tool.

The Writers Strike vs Progress

December 16th, 2007

I am addicted to my TV. I have seen the bumper stickers that say to throw away my TV. I hear people tell me to read a book. I don’t care. As far as I am concerned, we are living in the golden age of TV (and I read plenty of books, thank you). While the networks are loosing viewers, the programs are actually getting better. Cable channels are now competing with quality, original entertainment, such as SciFi (Battlestar Galactica), FX (Rescue Me, Its Always Sunny in Philadelphia), and TNT (The Closer). Shotime, HBO and Cinemax have all gotten in the game of original programming in recent years. The big four have had to step up their game as well. I don’t know if there has ever been a finer hour of TV than the pilot episode of Lost. Well, maybe that moon landing thing.

At home I have the full set-up for television viewing. I have a 56″ wide-screen HD television hooked up to an HD Dish DVR, DVD player, and full surround sound. With the DVR, I can record 1 HD Dish channel, 1 HD local channel, one SD channel, and watch a 3rd HD or SD local channel directly off the air on my TV, all at the same time. The one thing I have avoided purchasing is either an HD-DVD or BlueRay player.  OK, you get that I love TV.

Television has been loosing viewers for the last decade. This is attributed to the Internet and to video games. One can spend hours online, reading free news, watching funny videos on YouTube, etc. On the video game front, gaming systems have become increasingly mainstream. We have had a couple of generations now that have grown up with gaming consoles. As adults, they continue gaming.  The next generation coming of age will not remember a time without the Internet.

As a TV addict, I am dreading what the writers strike will do to original programming this winter and spring. Dread may not be a strong enough word for hours of crappy game shows and “reality” TV shows that are sure to fill the airwaves.

The long term impacts promise to be much more profound. Traditional media has been slow to get the implications of recent progress. I am afraid that they are ill equipped now to recover from the damage that may be done with a long term strike. Studios have gotten greedy, and don’t want to share the income from new revenue streams like DVD and the Internet. Others are in a prime position to take advantage of this. The Mark Cubans of the world could step up and create *real* online TV. Imagine quality shows starting up on the Internet. The next Veronica Mars, Boomtown or Firefly (three great shows that were canceled by networks) could come from an Internet. Writers, in need of cash, might be very open to new arrangements with non-traditional media companies. The talented imaginations that were writing for TV yesterday could be writing for the Internet tomorrow.

In the big pictures, the traditional media companies have a lot more to loose that the individual writers. I might be willing to put up with some crappy TV next spring if real change can come to the entertainment industry.

Or the strike might be over tomorrow.

Visual Thesaurus and Type Names

December 14th, 2007

When I am writing new classes and libraries, sometime I get stuck with the silliest of things: what to call a new class or class member. About a year ago I stumbled onto Visual Thesuarus. If you don’t click over to that site, let me explain to you what the people at ThinkMap have done that is so clever. They have taken a rich lexicon and bolted a very nice Java GUI onto the front of it, representing links between words visually. It works very well, but there is one problem I usually run into. The people at ThinkMap actually want money to use their product, and offer a limited trial version online.

Visual Thesaurus Trial Dialog

Still, I manage the get around this restriction which seems to consist of a limited number of lookups. I usually find a good term before I reach the threshold.

vt1.png

 

vt2.png

The visual interface is nice looking, and its functional. In the example above, I searched for “factory” to produce the first screen shot. I then clicked on “mill” which created the rendering displayed in the second screen shot.

When I first stumbled onto this over a year ago, I immediatly wanted to duplicate the interface. At the time I was just getting into WPF, so I spent a weekend writing a simulation of the GUI. As it turns out, it was not that difficult. The real problem here is having the right data. A well stuctured data schema with a sufficiently large dataset, plus software that can efficiently search the dataset is the real key behind this type of application.

As it turns out, there is this little school in New Jersey called Princeton that has been building a fantastic, open source lexicon called WordNet. This dataset is exactly what is needed to build an open source version of Visual Thesaurus. When I learned of WordNet, I got very excited. I thought, “I could build one of these in Silverlight and put it on the web.” Whenever I get a thought like this, I go through several stages:

  1. Wow, I have a great idea!
  2. Wow, I have the tools to do this!
  3. I can start this weekend.
  4. Hey, if this is a great idea, maybe somebody else has already thought about it.
  5. Search Google.
  6. Crap, somebody else did think of it.

It was at step #6 that I stumbled onto Visuwords.

vw1.png

The Visuwords site uses the Wordnet database and Adobe Flash to provide a very “Visual Thesaurus like” experience. The interface is not as clean, but it does get the job done for free. This project highlights what is often the difference between pay software and free, open source software. The Visual Thesaurus has a cleaner design, a more intuitive interface, and is faster. I spend time at both sites. I continue to use the Visual Thesaurus web site out of habbit, but I use the Visuwords site on occasion, especially when I need to do a more extensive search that will trip me up with the trial software requirements at Visual Thesaurus.

Self Reliance vs The 15 Minute Rule

December 8th, 2007

When I took my first lead developer role I implemented a 15 minute rule. It basically said that if there was a technical problem that stumped a programmer for more than 15 minutes, then that programmer was to get some help from a coworker. The rule worked very well in a small web shop (pre-AJAX). Almost all of our programmers were students at a local engineering/science college, and while they were smart they did not have a lot of experience (nor did I). I put the 15 minute rule into place so small problems did not turn into big ones. It works very well.

Ten years later I find myself as a senior developer at my company. People come to me for help, and the problems are not typically the small “15 minute” variety problems. The software the my fellow developers and I work on today is much more complex. Fifteen minutes is probably not enough time for a developer to research a problem before getting help from someone else. Still, some line must be drawn. When does one quit spinning their wheels and ask for help?

With programmers, this can be a difficult decision to make. There are several things to consider. First, many of the programmers I work with now and have worked with in the past take pride in their work and their knowledge. Admitting defeat or a lack of knowledge is not easy for most people, and certainly not for these guys. There is also a level of tunnel vision that can occur when working on a problem. I have accidentally worked through lunch more times than I can count because I was focussed on a problem. This is not uncommon amongst developers.

I have always liked the idea of working in a team, but I also like the idea of self-reliance. I like to be able to figure stuff out on my own. It is fun (yet sometimes tedious) to learn a new concept.  In ancient Japan, marshal arts were taught by example only. Any particular move, throw, kick or striking motion was not explained, but simply demonstrated. The student got the lesson wrong over and over until they finally got it right. Many traditional marshal artists that follow Ju Jitsu or Aekido today still believe that this is the best way to teach. They contend that the lesson you learn on your own is the one you have learned learned the best. Today’s business world is not ancient Japan and we, as business programmers, do not have the luxury of taking our time to learn a concept in this fashion. This is where the team comes into play.

How do we balance learning a new concept and getting it done on our own with relying on team members for help?  I have found that drawing this line for myself can be very hard. When do I give up reading the web articles, books, etc, and go ask someone for help? When do I got to my boss and ask (beg) for training or a new book?

Drawing this line for someone else is a much more complicated issue. When a fellow programmer comes to me with a technical problem, I am expecting that they have done some amount of debugging and research on the issue. If this is the case then I am more than happy to help out. It doesn’t really matter how hard or simple the problem, if the programmer is a seasoned developer or hopelessly green. If that person has made the effort on their own to figure something out, and come to me for help, I feel obliged to offer whatever help I can.

Sometime this is not the case. What happens when you start acting as a crutch for another developer? If the other developer is not making any real effort, not trying to learn anything on their own, then I believe I am actually doing a disservice to that developer by helping them. When a developer shows up in my door with a bug and has not even bothered to step through it in the debugger, then the choice is obvious but not easy. In this situation, I need to tell the developer to go back to their desk and debug the problem. How to do this in a polite way is not always obvious.

The same is true for a developer that is truly learning a new concept, aka “on the job training.”  I don’t feel it is my job to train developers.  If a developer comes to me and asks, “How does Windows Presentation Foundation work?”, I would probably give them a 10 minute rundown of the technology and point out a few good books on the subject for them to use.

From a personal perspective, I have found that self-reliance has powered my understanding of software and technology. There is nothing like trying to do it yourself and failing, and failing, and then succeeding to drive home a lesson. The ancient Japanese were correct in this respect.  If I have the time, I usually try to learn it on my own.  The time spent usually pays off several-fold.