There may be one or two readers out there who vaguely remember that, not long after I started this blog, I invested a decent chunk of money on some books on software and related subjects. I quickly discovered that the job I had at the time really didn’t leave me with a “I’m going to go home and read lots of technical books” feeling, so things didn’t progress nearly as well as I would have liked. I read a chunk of Code Complete [US] [CAN], but even that faded over time. I think I’m currently only about a third of the way through that book even though I started over a year ago.

About a month ago, deciding I wanted to take a break from Code Complete, I started reading Peopleware: Productive Projects and Teams [US] [CAN]. It took me about three weeks to get through it, reading it mainly on the bus to kill time, but it was a distinctly fun read.

For those who are unfamiliar with the book, the book is a little more than 200 pages of authors Tom DeMarco and Timothy Lister passing on their managerial wisdom. With years of experience in the trenches developing software, and also consulting with various companies, these two men have quite a bit to say regarding how best to construct and keep productive software development teams.

The book is quite obviously directed towards those in (and hopefully just entering) the role of project manager for a software product. I can’t review this book from that perspective, however, since I’m only three years out of college and still quite solidly in the “lowly peon” stage of my career. Truthfully, I hope never to become a manager of people since my limited experience with any authority shows that it’s just not for me. Besides, I know that since I like the idea of having power, that is an absolutely awesome reason not to give me any. With that said, I’ll try to review this book from my own non-managerial perspective.

My simple (and facetious) advice for those who feel unsatisfied by their work environment, as I was at my last job, is this: Don’t read this book; it will only depress you.

While reading this book, I couldn’t help but notice just how many things described in its pages reflected my own negative feelings towards my previous employer. To make matters worse, they cited books and studies and legitimate sources! I discovered that there exists hard evidence that not only could my environment have been better, but that what I had was actually working against me!

This is actually a fundamental problem that a lot of people should probably have when reading the book. No workplace, not even the highly acclaimed Google offices, meet the high standards put forth in this text. That’s the point, I believe. Much as a good developer strives to become a better one, so too should a good employer also strive to improve.

The authors’ explain that good knowledge workers (i.e. those whose main task is to think about a problem, as opposed to those performing some manner of manual labour) need three things to be successful:

  1. Knowledge workers need to be given what they need to succeed. This means things like providing a quiet environment in which to work. Open office environments may seem cost effective and appear foster teamwork through ease of communication, but they’re actually sabotaging your bottom line by wasting workers time by breaking their concentration.
  2. Knowledge workers need to be treated as individuals, with varying needs which will almost certainly differ from some, perhaps most, of their colleagues. This means that although an office environment should be built first for general success (based on actual studies and statistics, rather than perceived cost effectiveness), yet it is essential to be flexible to the needs of the individual.
  3. A managers job is to support the knowledge worker, since it is the knowledge worker, more than anything else, that directly affects the bottom line. This means a good manager should be able to check his or her ego at the door, beware of any “alpha male” tendancies he or she may have, and work hard to keep distractions to a minimum.

Getting these three things right is excessively hard work. To get even close to getting all three of these things working optimally should be seen as a monumental success. So if you do decide to read this book, try not to become too distraught over the seemingly Utopian environment it seems to describe. You’re likely not working in an environment which is perfect, but no one really is. With a little work, however, you can begin to effect change in your environment and take a step closer to office nirvana.


Side Note:
I’ve decided that my next task will be to read The Structure and Interpretation of Computer Programs (SICP) [US] [CAN].

I’m going to work through the entirety of this book, including all exercises and projects. I realize that this is a lofty goal, but I’m certainly going to try. As I work through the text, I will endeavour to blog about my progress, section by section, the whole way through.

Wish me luck!

A Few MySQL Issues

October 1st, 2009

I got really disillusioned with the StackOverflow Offline Viewer (which I’m calling FlowOnTheGo, at least for now) last week when I tried to load just the question/answer bodies into a testing table I made in MySQL.

The first issue I ran into had a lot to do with escaping quotes. Namely that I wasn’t doing it at all. In a moment of clarity, I realized that I could just use parameterized queries and everything would be ok. This was actually largely true, but surprisingly I was still getting a fair number of problem rows. After a bit of investigation, I discovered that the common thread between these rows was that they contained unicode characters. I didn’t understand how this could be, because I looked into it a bit and found articles which told me that “as of MySQL version SomethingLowerThanI’mUsing the default charset is utf8.” UTF8 supports unicode, what with it being right there in the name and all (Unicode Transformation Format), but unicode was choking my poor database.

As it turns out, the default charset for my particular installation was latin1, not utf8, so it found unicode characters to be weird and scary things. I changed the charset, and eventually a few other settings related to data transmission, to utf8 and all was right with the world.

All was right, that is, if you happened to have 10 hours to watch the database (in the words of Yahtzee Croshaw) “grind itself retarded.” As it turns out, a program which grabs only one record from an XML file at a time, nicely packages it up in a parameterized query, and sends that one lonely record off to the database is simply not a fast way to get the job done. I did toy around with sending more than one record per INSERT query, but it turns out that that’s just not much faster. Also, you have to be careful about how large your query becomes, because by default you can only send up to 1MB at a time, and I’d really rather that not happen when I release this to the public.

I asked StackOverflow for quick ways to load the database, and the best suggestion I found was to convert my XML data into a CSV and use MySQL’s LOAD DATA command to pull it into my table. I gave it a shot, but once again forgot about the quotes. When all was said and done it only took 3 minutes to write the CSV file and another 3 minutes to load it into the database. I’d call that a significant improvement.

Next on my list of things to do is finding a nice way to preprocess text before sending it to the database. I need to do this for three reasons:

  1. MySQL’s FULLTEXT indexes, by default, won’t index any word under 4 characters in length. This means that unless I ask everyone who installs the application to modify this server-wide, words like PHP and SQL won’t show up when you search for them. To get around this, I want to change words like XML into XML_Edit_PaddingText.
  2. Characters which are not alphanumeric, single apostrophes, or the underscore character break words. This means that, word length limitations notwithstanding, the term C# and C++ would each be truncated to C. I want to edit these to C_Edit_Sharp and C_Edit_PlusPlus, respectively.
  3. MySQL’s “Stop Words” list (i.e. words which aren’t indexed because they’re too common) is a bit too comprehensive for my needs. I think the words ‘get’ and ‘value’ would be relevant enough to programming-related searches that they should be included. These will become get_Edit_StopWord and value_Edit_Stopword, respectively.

I have a feeling this will be a little trickier than I would like, but that’s part of the fun of this project.

Working In Peace

September 5th, 2009

So far, I’ve done a terrible job of getting anything done. The peer review tracker I’m supposedly building is often quite far from being on the forefront of my mind. I’ve attributed this largely to the fact that it was meant to be for my employer, and we’ve since parted ways. I think there’s another aspect at play here though, and that’s the fact that I don’t have an adequate place to study the books I want to study or code the things I want to code.

I live in a one bedroom apartment with my girlfriend Cyndi, cat Leo, and two birds (Tink and Houdini, though I always have to think about the latter’s name as I tend to call him something else entirely). I used to have this apartment all to myself, so I saw no major flaw with having my computer desk in the living room. Now, the flaw is obvious: privacy, or rather the lack thereof. Even if I wanted to move the desk into the bedroom, I don’t think I could because of factors like space, the awkward nature of the corners of the room, and the fact that my desktop is largely Cyndi’s now and I don’t want her to have to isolate herself in the bedroom to use it.

Cyndi is actually really good about giving me space if I want to try to work on something, but most people would probably tell you that your living room isn’t the best place to read technical books or develop software, since there are just too many distractions. Thus, I needed to look elsewhere for places to work.

The first place that jumped to mind was Starbucks/coffee shops in general. I figure it wouldn’t be too hard to find a place that wasn’t overly loud, but other factors led me to discard the idea. Mainly, I don’t like the idea of taking up space for paying customers, as I assume the staff wouldn’t be too happy about that. Also, I don’t like being forced to pay every time I want to code. Don’t get me wrong, I like coffee, I just don’t like the idea of paying $10 for a few cups so I can feel justified to work for several hours.

Next, I considered working at a campus library. I’m not enrolled there, so I didn’t think I’d be allowed to use the university’s libraries. When I was in college, my friends and I used to spend a lot of time in the library studying/hanging out, so I knew it would definitely be a good idea. I sent an email to each of the campus libraries and asked if the general public was allowed to study there, and they said that was absolutely fine, though their wireless system was only available to students. This environment seemed like it would be my best option, so that’s what I decided to do.

I’m still working out the schedule I want to follow, but it looks like I’m going to start working at the library 3-5 days a week for a few hours a day. Hopefully this will keep me structured and make me more productive.

The lack of wireless is also a motivator for a new project which I’m going to give precedence over the peer review tracker. Since I won’t have access to the internet, I wanted to start downloading things like the PHP documentation, the Java API and tutorial, and the MSDN Library. These are all readily available, but I’ve become addicted to StackOverflow as well, and I’d really like to keep an offline copy of that as well. The site is licensed under the Creative Commons and the developers release an data dump once a month of all the sites content. This sounds awesome, but unfortunately for me it’s all in XML format, which means it’s not as easily searched as something like MSDN or the StackOverflow website itself. My new project, therefore, is to create a desktop application that will load the XML contents into MySQL and provide an interface to all the sites questions and answers, along with a reasonable search feature. I just have no idea what to call it. Any ideas would be appreciated.

So, a new productivity plan and a brand new project. I think next week will be the start of something really fulfilling.

Notifications

June 28th, 2009

A guy I work with has known my girlfriend since they were both kids, so he knew what I was up to. There was a bit of a discussion at work a few days ago, when he casually mentioned the project to another developer.

I ended up involved in the conversation, and I ended up getting some good feedback on some of the things I should be doing. We also tackled a major problem with this application: notifications.

Notifications are a fundamental part of my Review Manager. Otherwise, we would just fall back into the same problems that we currently have with the review spreadsheet (oddly, the non-shared spreadsheet that can only be used by one person at a time..), and that’s that no one ever checks the damn thing. If nobody knows you’re looking for a review, nobody will do your review. This is why so many people, myself included, tend to just spam the team with an “I need an XYZ review” emails.

I’m hoping my app will solve this problems in two ways:

  • First, everyone will have the app open because it will minimize to the tray. This makes it quick to check if you’re in the mood to pick up a random review, and it’s easy to access when you need to broadcast that you need something done
  • Everyone gets notified (once by default, and only if you’re allowed to do that type of review) that someone needs a review done, hopefully in a non-invasive way.

The main problem I had with this was determining how to display the notification without interrupting the users workflow.

After a few searches on Google and StackOverflow, I came across these two overrides:

protected override CreateParams CreateParams
{
   get
   {
      CreateParams bp = base.CreateParams;
      bp.ExStyle |= WS_EX_TOPMOST;

      return bp;
   }
}

protected override bool ShowWithoutActivation
{
   get
      {
         return true;
      }
}


The CreateParams override simply adds the option to push the form to the top of the Z-Order. This is so common that WinForms have a property already built to include this – Form.TopMost. The problem with using TopMost is that it will activate the form, stealing the focus away from the user. Since this is exactly opposite to what we want, we can’t use it. The CreateParams override will handle this functionality for us, and the ShowWithoutActivation override does exactly what it sounds like. The result is a form which is displayed above all else, but that doesn’t take the focus away from whatever the user is working on.

I decided to also allow the user to define for how long the notification is displayed. This is simply a second constructor for the form, and is in fact the only constuctor with any logic in it. The constructor without a timeout simply passes the buck onto the one that does, along with a default value of 5 seconds:

public FadeNotification (string title, string message, int timeout)
{
   InitializeComponent();
   DisplayDuration = timeout;
   tips.SetToolTip(lblMessage, message);
   this.Text = title;
   if (message.Length > MAX_MSG_LENGTH)
   {
      message = message.Substring(0, (MAX_MSG_LENGTH - 3)) + "...";
   }
   lblMessage.Text = message;
   State = DisplayState.Appearing;
}

// if no timeout is specified, use a default value
public FadeNotification(string title, string message) : this(title, message, DEFAULT_DURATION) { }

Another thing you might notice in this snippet is that I’m a bit lazy with the message. I played around with the label on the form a bit, and generally hated how it was coming out. What I decided to do instead, was to make the label the size of the form, and center it. I set the font to a nice(ish) looking size, and sent it on its way. If the message gets long enough to wrap, it looks like crap, so I just cut it off. For what I’m using it for, the maximum length I set is more than sufficient. If it’s not, the end gets chopped off and replaced with an ellipsis (sort of, since there actually is an ellipsis character which I’m not using for no particularly good reason).

This new form became revision 3 (and 4, since I left a literal in where I passed to the other constructor.. oops) in my SVN repository. There should have been more revisions relating to this, I know, but this is basically a sandbox which became too valuable. It wasn’t even originally in the same project as my main stuff. I’ll have to learn to play with my working copy more, but this source control stuff is still new to me.

The code is available in a RAR file if anyone wants to review it. I haven’t decided how I’m going to formally release this when I’m done the project, so for now lets just consider this my copyright from now. If you would like to use this in your own project (you won’t), drop me a line and force the licensing issue. It’s likely going to be LGPL’d at some point, but who knows.