Tuesday, 30 September 2008

Custom WinForms Controls - Forcing “Always on Top”

Having read the following question from MattBerry on the student forum for the MCAD I am studying towards:

Does anyone know how to make a custom control the top most control on a
form i.e. its z-order.
I know forms create the z-order in the order the controls are created,
and I know you can use the control.BringToFront method after all
controls have been created.
What I want to know is, is it possible to set this z-order in the
custom control's code, so that it can be encapsulated?

It sparked my curiosity, can it be done? I have never tried anything like this myself. And yes, there is a side of me that would get REALLY pissed off with using a control that did this, but I thought “what the hell?” lets have a look and see what we can do.

Now, a bit of disclosure, it has been a while since I done any Windows development, so this may well be possible to do a lot easier, but hey, it took me 15 minutes :P

Getting Started

I had no real idea where to start as I only remember the most important properties/methods for WinForms controls. So I created a class for a new control, then sat there going through the Intellisense to see if any of them sparked my curiosity:

image

I pretty much set here looking at this for 5 minutes while I got reacquainted with the Control class.

Heading Down the Right Path

I came across a property that caught my eye:

image Looks interesting right? I then checked out it’s article on MSDN. It turns out it tells you if this control is “top level” in the control hierarchy (i.e. is it contained) and got the nice sense of disappointment as I realised it would not give me that I really needed. But it did get me thinking, “if I know I am in a container, then I should be able to get a reference to the container, right?”

So I started scrabbling around to see if I can get a reference to the container control, Control.GetContainerControl sounds like it will do the job nicely, so I hacked together some code:

   1: protected override void OnCreateControl()
   2: {
   3:     base.OnCreateControl();
   4:  
   5:     // Determine if this is the top level Control.
   6:     bool isTop = this.GetTopLevel();
   7:  
   8:     if (!isTop)
   9:     {
  10:         // Bubble Up
  11:         Form container = this.GetContainerControl() as Form;
  12:         if (container == null)
  13:             throw new 
  14:                 Exception("Control must be on a Form!");
  15:  
  16:         container.Controls.Remove(this);
  17:         Control[] temp = new 
  18:             Control[container.Controls.Count];
  19:         container.Controls.CopyTo(temp, 0);
  20:  
  21:         container.Controls.Clear();
  22:         container.Controls.Add(this);
  23:         container.Controls.AddRange(temp);
  24:     }
  25: }

Yes, I agree its not too pretty, and could be more efficient etc, but it seems to do the work. So what is it doing?

  • First we call the base method, as we tend to do that for most overrides to make sure we don’t miss any important base logic.
  • We then determine if we are a top-level control, or a control within a hierarchy via GetTopLevel();
  • If we are in a hierarchy, then we simply:
    • Remove our control from the container’s Controls collection.
    • Copy the rest of the controls in the container to a temp collection.
    • Clear the collection.
    • Add our control back to the container (now the first control).
    • Add the controls we saved back to the collection.

A Quick Test

To give it a quick test, I added the following rendering logic to paint a box:

   1: protected override void OnPaint(PaintEventArgs e)
   2: {
   3:     using (Graphics g = e.Graphics)
   4:     {
   5:         Rectangle bounds = new 
   6:             Rectangle(0, 0, this.Width-1, this.Height-1);
   7:         g.FillRectangle(Brushes.Cyan, bounds);
   8:         g.DrawRectangle(Pens.Black, bounds);
   9:     }
  10: }

I then chucked our control on a form and added a button on top of it (you can right click and say “bring to front” if required).

When first added, it looks like it is not working, but that is because the ZOrderControl’s logic has not had a chance to fire.

Hit F6 to build and see what happens.

image image

NOTE:

This has been far from tested and of course there may be issues with messing with the control hierarchy. I simply wanted to find a way to do the goal required. I tested obvious things like control events still firing etc, but use this at your own risk!

Share:  digg it! del.icio.us Live Technorati Facebook

Monday, 29 September 2008

StackOverflow – Followup Since Release to Public Beta

StackOverflow has been in private beta for a while now, and the community has exploded. I thought I would take a bit of time out to review some of my thoughts following it’s release to the public.

These points are not really in any order or organisation, so forgive me if it’s a bit of a poor read, I have literally been jotting down ideas for this post as and when they popped in to my head. My apologies if it’s all too random :)

Some Big Names Enter the Affray

So we have had a couple of big names get in to StackOverflow including:

(If anyone else has noticed some other big names, let me know and I will get this list updated)

This is not only nice to see (because they are good guys) but the technical expertise they will bring to the community will be immense.

There is a good side point here as well, we all know Scott is a great geek. He’s really switched on and his blog has some great content that has taught and inspired me a lot.

After Scott posted his first question on StackOverflow, he posted the following tweet:

I asked my first LazyWeb, er, StackOverflow question. Now, I wait. http://bit.ly/1sZcmq

It was a good question, and funnily enough, because it was a good question (i.e. one that requires either solid knowledge or good digging skills), there was no “Bob Munden” – the “fastest gun in the West”.

Scott later posted the answer which he had found himself, within 10 minutes of asking. Nicely done Scott. I thought was a great demo of how the easy questions get flooded by mediocrity and good questions seem to just sit there because people don’t really want to think. Some of my toughest questions have remained unanswered, it seems people don’t want to “work” for their rep.

Subjective Posts

This has been a real bug-bearer of mine since private beta. Several users got in to the habit of tagging subjective questions with the “subjective” tag. Yes, I was doing this too at one point since I thought it was a “standard”. It dawned on me one day that it was ridiculous. When was the last time you answered a question without being subjective? To be clear, lets review what “subjective” actually means:

  • Proceeding from or taking place in a person's mind rather than the external world: a subjective decision.
  • Particular to a given person; personal: subjective experience.

Humans can only answer questions based on their experience and knowledge, so ipso facto, everything on StackOverflow is subjective.

I started to revolt against it and posted a nice message to any would-be taggers on a question of mine. Following this I think I have slowly been winning the war against the “subjective” tag. As a side note Mendelt has also raised some great points in his question about the “allowed questions policy” being too restrictive, check it out.

Mod Wars!

This has been great fun, recently some of us mod’s got into a nice little flame war on a question of “X better than Y” style questions. Check out the comments on the question. I personally think we need to be more open and educate people on how to discuss on StackOverflow rather than just close everything off. What are your thoughts on this?

Poll-Like Questions

It thought I would try something new with the StackOverflow system. I was thinking sometimes we just want a “yes” or “no”, so could we use the system like a poll?

I posted the following question, basically asking if the community at large thought it was a good idea to have a “pet project”. While TBH I was expecting a resounding “yes”, it was nice to see how the community responded. There was a little bit of resistance to begin with, but it has turned out that its actually quite useful for getting clear, succinct answers.

UserVoice? SHOUT LOUDER!

This is an interesting one. One of the most hated things about StackOverflow is the way to request features/notify of bugs. It uses a service called UserVoice, which to be fair, I think it really being used for something it wasn’t really designed for.

Take a look at this request, where it is raised that is difficult for people answering/modding that a question has been closed, because nothing changes about its appearance in the question list. Now, Jeff’s response really hacked me off (as you can see in the comments) since he didn’t grok the point being made, and rather than ask for clarification, he just smashed it down with  “DECLINED”. What’s really funny is that Jeff has backtracked and actually implemented a solution now. Nice!

Mendelt also made another good point on UserVoice in that he has stopped using it simply because so many of Jeff’s reactions on UserVoice are similar to the above (here’s the tweet). So in essence, is it REALLY worth going there? Many of the accepted ideas are ones Jeff already had, and a lot of the new ones, DENIED!

So, what are your thoughts on the above? Does it spark any thoughts in your mind that you may want to see here as well?

Share:  digg it! del.icio.us Live Technorati Facebook

Tuesday, 16 September 2008

GTD – Keeping “Fresh”

For my next instalment of my GTD journey, I want to talk about keeping the old “noggin” fresh. This is an often overlooked part of getting things done. I want to talk about getting over “brain fatigue”.

To put it simply, if your brain loses momentum, YOU lose momentum. Due to this, as part of wanting to work smarter (not harder) we should look at it and see what we can do to fix it.

Look at the Problem

Now, not everyone may suffer from this. Some people may be able to do 8-9 hours of work and go home and do everything else and still feel pretty refreshed by the end of the day. I however, can not. Far from it in fact. Here is my current take on the situation:

I am a software head. I write software for a living, I study software, it is my career and my passion. While this is awesome, it also means I am sat in front of a computer for an average of 12 hours a day (holy crap even I never realised it was this much until I worked it out!). This means I am always typing code, thinking about code or looking up code for most of my conscious time. This makes my head tired.

For me, I tend to get tired about the same time(s) each day. Around lunchtime and when I am heading from from the office. This kind of makes sense. People tend to naturally feel sleepy after eating and after doing 9 hours work, of course I am bloody tired.

When it hits me, I find it REALLY hard to focus on what I am doing. Hell sometimes I am struggling to stay awake at my desk. Sometimes I have never been able to get focused following a “crash”.

I don’t think sleep is an issue. I get a minimum of 7-7.5 hours a night. Medically, I am perfectly healthy.

So we have identified here that:

  • When it hits me, its VERY disruptive to my work flow.
  • I have times where I feel tired. There is a regular pattern.
  • It happens a lot (i.e. daily) but the good thing is that its regular (I know roughly when it is happening).

Now, I know some people don’t have the luxury of having a regular “cycle” (especially those of you with children!) so this is why it’s important to think about your individual situation.

Think!

I started thinking.. Why do I suddenly start to feel real tired? Yes, I have always known people feel naturally tired after eating, but it never happens at home (studying or working), or when I am out dining with friends? What’s the difference? So I began to start comparing my two main working locations.. Work, and home.

Then it started to strike me. It really is my environment. I have a boring office, with a crappy chair, with nothing going on but the cursor/caret moving in front of me as I do my work.

At home, I can have the windows open with fresh air coming in. I can hear the birds outside, the rain coming down (I am in England, its the “norm”). A comfy chair. No office noise. I can work in my boxers if the need takes me (apologies for any nasty images). I can stop for longer than 20 minutes and not get a boss thinking I am trying to pull a fast one.

To put it simply: Humans aren’t cut out for this crap.

We are creative, sensitive individuals who crave stimuli. It’s so simple, but the problem is we don’t [all] have great offices, we can’t go to work in our underwear and bosses like to see people doing work rather than drinking coffee and relaxing.

Solutions?

Get Stimulated! Here’s some of the things that I have done to help me, these may work for you, or may need some “tweaking” to suit your needs:

  • STOP! First and foremost, don’t try and fight it, you will lose.
  • Listen to different music. I am a rocker, a metal-head. I love it and always will. However, the trouble with it is that most of the time it pushes the testosterone and adrenaline up, making it hard for me to relax. But when the old “sleepies” hit, it doesn’t really help me because I am used to it. So I ended up on Napster checking out all sorts of random music that I don’t normally listen to, the most prominent being New Age (this made me chuckle as it is so “not me”). I couldn’t believe the effect it had on me, it actually chilled me out a LOT and I could almost feel my brain emptying and become less stressed. FYI, One group that I play a lot is Enigma. Aside from all of the above, it opens your brain up to new aural experiences.
  • Don’t do “boredom” things. Surfing Boing Boing, YouTube, FAIL Blog and the like for cheap giggles will not help either. Yes, you may get a little lift, but none of them are getting your brain doing anything, so as soon as you go back to work, you are back at square one.
  • Engage with people. Talk to colleagues, if you are feeling it and a colleague pops out to grab a coffee, go and chat for 5 minutes. Talk about whatever you like, provided you are both interested. You will both feel refreshed when you return.
  • Brainstorm. This is my personal favourite because you can brainstorm about other things you are working on while not working. These can be future projects/features, side projects, blog posts (guess where this one came from) and so on. Nothing beats getting away from the screen with a pencil and paper and just unloading your thoughts. Remember, brainstorming should be a natural thinking process, don’t force it. Just relax and yet your thoughts lead the way.
  • Do NOTHING! Yup, you heard it from here, tell your boss to send the complaints to me. I don’t care I am trying to help you and they should do the same. Sometimes just getting out of the office, sitting down with some chill-out music on with your eyes closed can work miracles for your mental state. I have also been doing this a lot recently too. I have literally opened my eyes after 5 minutes “shut off” (closed eyes, good posture, music in ears – NO INTERRUPTIONS) and felt as refreshed as when just waking up.
  • Scribble / “Doodle”. Sometimes just drawing rubbish can really take your mind off of things. Stupid little faces, animals, planes, comic book heroes, whatever. I often do this while brainstorming. As soon as a “thought chain” stops. I doodle around previous thoughts. For example while brainstorming this post, the “STOP” idea ended up with a big red stop sign scribbled next to it. The music point ended up with some weird bug thing with a smile and music notes flying around its head. Be creative, it doesn’t need to be serious.
Contributions from Commenter's

Take a walk! Getting some blood flowing around your body can really help you wake up and if you do it soon enough you won't start to feel tired either.

Summary

The above are things that I have found really useful for picking me up and putting me “back in the game”. Normally this only takes 10-20 minutes. This is much better than a total afternoon crash where I have literally not been able to get focused for the entire afternoon. Hell, some of my colleagues disappear to the restroom for longer periods.

So, will the above totally work for you? Probably not. I just wanted to post my thoughts so it may be of some help for you. If you only take one point and get a little bit more productive because of it, I am happy. :)

Feel free to share any ideas that work for you, be great if we can get some more recommendations on here!

Special thanks to those that get involved and help improve the post! :)

Share:  digg it! del.icio.us Live Technorati Facebook

Sunday, 14 September 2008

StackOverflow - CrackOverflow or StackOverblown?

logo link to homepageStackOverflow is finally due to come out of private beta this Monday (15/09/2008), so I thought it was about time I got my thoughts down about the new programming resource/community that is the brainchild of Jeff Atwood of CodingHorror.
StackOverflow has caused quite a stir within the programming community, already being dubbed "CrackOverflow" due to its addictive nature, but has some of the hype really just made it "StackOverblown"?
Note: Any links to user profiles or questions on StackOverflow are not intended to be personal attacks against them, they simply reinforce some of the points I am trying to make here. Also, links to StackOverflow will require access to the beta if it has not yet been released.

What is StackOverflow?

Straight from the "About" page on the StackOverflow blog:
It’s a collaborative programming community venture between Joel Spolsky and Jeff Atwood.
In my opinion, it's a great idea, and one that is much needed by the programming community as a whole. We have tons of forums around, all doing their own thing. But we need a centralised location with good quality guys/girls there. Most of the forums I contribute on seem to be rapidly deteriorating in quality.
StackOverflow aims to do this by having some "unique" features:
  • A rep system which allows users to vote on questions and answers given.
  • "Badges" that are awarded for users, their questions and answers meeting certain criteria.
  • Members can edit and work with all content (rep permitting) similar to that of a Wiki.

The Positives...

So, lets start with the nice stuff so I have unlimited rant space for the negatives ;)
The "Honeymoon" Period was Awesome
I have to admit, when I first got into the StackOverflow beta, I was proper "loved up". I was singing its praises to every geek I knew, and even the "normies" (who stared back with glazed eyes). I had a real good feeling about it and liked the way it was going. I thoroughly enjoyed what was happening and thought the CrackOverflow title was well deserved. :)
It's Quick and Easy
Much like the drunk girl at the party, it's easy to pick up, doesn't take much talking to to get down to business and is easily accessible. Authentication is done via OpenID so there is not another password to remember. Profile information is minimal and the site speed is, well, speedy. As well as the actual site being speedy, it's also very fast to get answers from the community.
I <3 the Rep System
I thought the rep system was a great idea. I am a firm believer that software is becoming, and should be a socially-aware affair. Humans are social. Software is used by humans. Ipso facto, software is social. The rep system allows the "cool" (maybe not a good choice of words for a geek community) to be elevated above Joe Average.
I <3 the Badges System
A fun little edge to the rep system, the ability to get "badges" or awards for doing certain things is cool. Inspired by the XBOX 360 GamerCard system, it gives you something else to "work" for.
I Like Jeff & Joel
Most geeks find it nice to see geek startups, especially geek startups doing well. I remember the good 'ol days when Google was this cute little search engine that not many people knew about and it worked. Yeah it kinda sucks they are now bent on world domination, but hey-ho. It was equally real nice to see Jeff &  Joel's ideas unfolding and seeing the site pick up speed. No matter what I say here, I always hold these two gents in high regard.

... And The Negatives

Sadly there are a few more of these, I guess I get more caught up in concerns with StackOverflow rather than doing my StackOverflow-sunshine dance. :(
Note: Some of these are merely usability/feedback points.
The Rep System
While the rep system is a huge plus, there are a huge amount of issues with it. It's a simple concept, but a complex ecosystem.
Farming/Seeding
There have been many questions that were created to simply get answers. Each answer and upvote means rep. This user in particular went through a phase of pretty much posting "What is <programming term>?". The user did not actually need to know the answer, they already knew it. They were doing so under the guise of "trying to build the library". This to me just reeks of "rep seeding/farming". Now, much like spam, if only one of these questions is upvoted, then the user has received "free" rep. So why not create a bot to simply start posting all the computer science terms I can muster? Yes, it may help the content of StackOverflow, but does that mean the user should get the rep?
It should be noted that this user did seem to stop after being flamed for it, however, the issue remains. This behaviour was only really picked up because they posted several questions in quick succession.
"The Bob Munden" (Fastest Gun in the West)http://www.shootingusa.com/LATEST_UPDATES/BobMunden1.jpg
Another problem that has been highlighted is the "fastest gun in the west" (who is currently Bob Munden). This is basically the "fastest fingers first" issue.. People that answer quickly tend to get upvoted and even accepted even if their answer is wrong. This problem occurs for three main reasons:
  1. The person answering does not read the question properly in their haste.
  2. The person asking the question most likely doesn't know they are wrong.
  3. The people upvoting don't read the question properly either, or they don't know and "have a hunch" (or both!).
This to me is a real serious issue. I have seen many answers that are outright wrong. Some have actually been upvoted way past the actual correct answer! My question on type enforcement for generics is a prime example! The answer posted by Jon Limjap actually led me down the right path (so I of course accepted) only received 3 upvotes. However, the answer by Lars (who was the first to respond) received 6 upvotes and was clearly wrong! He failed to read my clarification and even edited later to "correct" and still didn't address my issue. I know people then did exactly the same and upvoted. If you read the edit history on the question, even he points out he read it too quickly!
"Community Mode"image
It was raised that if the community contribute to a question and improve its readability/content etc, then the original user should not continue to get the rep for it. Now, IMO this is completely wrong. I had originally posted my thoughts (which a large number of members agreed with) as an answer to a question airing my thoughts. In short:
  • The original poster should always maintain true ownership of the question.
  • Jeff actually agreed with this at one point, but now seems to have u-turned on this as users cannot reclaim control of it.
  • If the question is such a mess that the community needs to work so much on it, then it should be requested that the original asker fixes it (or it is fixed once). If that much discussion is required on a question then it is a badly worded question.
"I Want the Rep, the Whole Rep, and Nothing but the Rep"
This is a classic attitude issue. There are too many arrogant geeks out there that just want to look good and somehow think a rep of 4000 makes them cooler than the other geeks. The problem is that geeks like this are bad geeks. These people just want to get as much rep as quickly as possible. They answer posts quickly and incorrectly, ask crap questions just to pull in little bits of rep here and there and generally just degrade the whole experience.
Question Quality
An obvious one really. We want good questions. StackOverflow is not Yahoo! Answers where anyone can ask anything. It's a programming community.
To get it into context, I ended up losing my rag one day and posting this sarcastic question: "What is a programming question?" (this has since been deleted). It had a wide range of interesting answers. The majority saying we want good, tough programming questions. Equally many said pretty much anything that remotely relates to programming.
Stupid Questionshttp://www.leeds.ac.uk/classics/resources/theory/questions.jpg
Now, we all like to think there are no stupid questions. Well, there are. I am a firm believer that any programmer worth anything should be able to research quickly and effectively. There is simply too much going on in programming to remember everything, so you need to find stuff, fast. There have been many questions getting posted to StackOverflow that you could Google (faster) and actually get most of the answer from the summary in the search results! I personally think [for the majority] this is just laziness and falls into the "rep farming/seeding" category as well we accentuating "The Bob Munden". Of course, I welcome questions from actual newcomers to the geek community.
"Good" vs. "Good for Me"
This is something I picked up on quite recently. I find that I tend to upmod questions not that I can answer, but those that I can't due to their difficulty. To me, a "good question" is one that makes me think, makes me curious and want to find an answer. However, often simple questions get upvoted more simply because they know the answer. IMO, this makes no sense! That's not a "good" question, it's just an "easy" question! For example, I had a real bitch of a question on "serializing large, complex objects to XML". I, and others found this tough, yet it only received 3 upvotes. Yet this question on "use of the var keyword", which is pretty subjective and requires no real thought at all got 21 upvotes! Can you say WTF?
Organisation
Since its launch, the rate at which questions are being posted has increased massively. In the mess of questions we need a way to be able to find ones that answer our question, or we can answer quickly!
Search Support
The search functionality is improving. However, is it still limited (for example, no OR search). It also has limited filtering options. One major problem for me is that it displays searches the answers as well as questions. So, you can end up with a page of results that point to one question (which may not help you). Tag searching is also improving but still limited and even misunderstood by its creator (see the comments).
Finding Your Stack
I am a C# developer. I work on Windows and ASP.NET applications. I know nothing about Java, Python, Ruby and the many other languages out there. I can offer limited advice on architecture and design. Now, currently, it is bloody difficult for me to find questions with the appropriate tags so I can assist. I propose:
"Smart Lists" - these should be lists that each user can create that you can specify tags to search for. For example, I could create three "Windows" (which searches for items tagged "C# WinForms"), "Web" (tagged "ASP.NET") and Architecture (tagged "architecture"). Now, a web developer who works on the LAMP stack may have a "Web" tab, but entirely different tags.
I am currently getting around this by having Launchy shortcuts set up for my stacks.
Sort Order's Applied to Questions
I find these can be kind of "weird".. I question their real use. This may be largely due to the problems described, for example the "by Votes" sort. Highly voted questions tend to either be rubbish questions (the first is the unofficial FAQ, 3rd is Bob Munden) or questions already answered. Do I want to see them? Nope. "Hot"? May not be on my stack, do I care? Nope. "Active"? Well, I don't see the real difference between this and hot so, nope.
Moderation
I think one of the biggest issues with user-driven content is managing to keep it under control. One problem the Internet has had since hitting the masses is anonymity. People love it because they can become an absolute asshole and no-one will ever know! Now, I am certainly not suggesting that StackOverflow users are asshole's, far from it in fact. But there needs to be some control.
Contested Answers
To help combat the problem noted above about the incorrect answers, I think people past a certain rep should be able to "contest" the answer (rather than just comment) this makes is very obvious to visitors that the answer is in debate, much like Wikipedia does with its maintenance policies/guidelines.
"Hit and Run" Questions
Questions that have been asked, but the user asking does not accept an answer. Yes, while "Votes" view will pushed voted answers to the top, I feel that experts should be able to accept that answer on behalf of the user who asked the question (so the person contributing gets credit). This should be obvious it has taken place, and of course the user can always "unaccept".
Comments Help, But Are Easy to Miss
Comments were recently added, which enable users to add notes to questions and answers. While these help a lot, they are hidden by default and they are not obvious when shown.. So they can often go missed.
Lack of "Solid" Guidelines
The guidelines set in the StackOverflow FAQ are really non-specific. There is no real attention made to moderation policy which I find deeply worrying, sometimes those with moderation powers can be worse than the users! I think this really needs to be addressed so those that are moderating are all working towards a common goal.

In Summary

I started out incredibly positive about StackOverflow.. This has now changed. Don't get me wrong I am still positive about it, but lets just say I am not holding my breath. There is still a lot of work to be done, and it is only going to get harder following it coming out of beta. Watch this space I will blog more and keep on this.
In my opinion StackOverflow could be the absolute best thing for the programming community, but has the potential to be one of the greatest failures, in that it's a great idea but implemented badly.
However, Jeff & Joel are smart guys, and I do have faith that they won't let it get to that. But, we are all human and no one is infallible. :)
What are your thoughts on the above? Do you have any points you would like to add? I know there is a lot here and I am bound to have missed something!
Share:  digg it! del.icio.us Live Technorati Facebook

Wednesday, 10 September 2008

GTD: Keep Things Consistent

I have found “keeping the flow going” is a real important part of maintaining a GTD process.

Knowing I had some great, accessible tools was fine, but I had another problem that slowed me down. This problem was that I used two different methods to get to the tools.

Tools I Was Using

At Home

At home I was using the (pretty damn good) Start++ from Brandon Tools. Now, I have been using this tool for a while at home (pretty much since I upgraded to Windows Vista) and been more than happy with it.

At Work

Since I use XP at work, I could not run Start++ so instead run Launchy. Again, this is a fantastic bit of kit. It looks nice, and has really started coming on well. There are also some great plugins available for it.

The Problems

  • Key Combinations
    • Start++ works with the Vista start menu, so to bring it up, I just press the WIN key.
    • Launchy binds to a key combination (I think it defaults to CTRL+Space, but could be wrong). I have it bound to WIN+ESC.
    • The different keys would get annoying, I often found myself at home smashing CTRL+ESC and wondering what the hell was going on.
  • Saved Settings
    • Start++ saves all of it settings in an XML file (I believe).
    • Launchy saves it settings within an INI file.
    • Every time I wanted to add a shortcut to a link etc, I would need to create twice, once at home, once at work.

What I Decided

In order for me to continue streamlining my work, I HAD to get rid of one of these. The main issue was not really the interface, but the hassle of needing to maintain two (pretty large) links collections in two different applications.

I therefore decided one had to go. Sadly, because I have to use XP at work, it had to be Start++ to leave. I am sorry Start++ you served me well.

Outcome

Although it sucked letting go of Start++, I am now MUCH more productive when launching applications/sites/whatever. My Launchy settings file is now synched between work and home, so whenever I change one, the other is updated. This means I no longer need to maintain two locations. The UI consistency is helping with the minor things such as hitting the right keys and looking in the right place.

Issues

Local Applications

In order to take applications installed locally (and normally in a different folder to the other location), I simply added a common path to both computers for the shortcuts to the applications in question (in my case I went for “C:\Launchy Shortcuts” how original huh? :D

This means I now have the exact same access route to all of my tools (both online and offline) when at work and home.

Business Applications

We all have business applications that we must use and either can’t don’t want to use outside of work. For example, I use Google Mail for all my mail, so I have no real need for Outlook. In cases where you must use business applications, ensure you push it to your accessible application as well – even if it is a one-liner saying “Read email from John sent xx/xx/xxxx in the Project folder in Outlook”. Keeping these notes still gets it out of your head, but keeps the item linked with your GTD process. If you need to have a printed copy, then download CutePDF or something and attach it to a mail and send it to your GMail (or whatever) inbox.

The idea here is to keep everything consistent. Some things may need to stray from the process (such as software requirements) but it doesn’t mean YOU should stray!

Summary

Keep the way you access your applications consistent. It’s important. Keep your brain doing the same process over and over and it will get quicker at it.

Share:  digg it! del.icio.us Live Technorati Facebook

Tuesday, 9 September 2008

TDD – Getting Started with Test-Driven Development

I have been expressing interest in getting up and running with TDD for quite some time, probably the best part of nearly two years in fact! (wow).

I have always struggled to get going though. In my previous job I was pretty much flying solo, and even though I am in a 6-man team in my new job, we still are pretty isolated (not my choice!).

Every time I have gone to the programming community and asked “how do I get started?” I pretty much got the same response wherever I went - “Just do it”. This was real frustrating because it can be so overwhelming, if you don’t know where to start, how can you start?

So I started to dig deeper for as many TDD/Automated Testing sites as I could, even if it was pages and pages of stuff that I didn’t want to know, if I got one little snippet of something useful, I would be happy.

I came across some great sites (links will follow). Some were very, very simple. Almost so simple that they don’t really cover the testing, they cover something much more important – YOU and YOUR MINDSET.

And this is it, the biggest problem was not writing and automated test, that’s just code, we can all code (OK well most of us at least try hard!). I have seen so many sites that use Debug.Assert or testing frameworks and cover those in great detail, but don’t actually approach the first major problem newcomers have, themselves.

So, here is my attempt at hitting on some of the key problems/questions I had when getting started.

I Don’t Know Where to Start?

  • Start afresh. Only think about writing tests when you are writing new code. This can be re-working of old code, or a completely new feature.
  • Start simple. Don’t go running off and trying to get your head round a testing framework as well as being TDD-esque. Debug.Assert works fine. Use it as a starting point. It doesn’t mess with your project or create dependencies.
  • Start positive. You are trying to improve your craft, feel good about it. I have seen plenty of developers out there that are happy to stagnate and not try new things to better themselves. You are doing the right thing, remember this and it will help stop you from giving up.
  • Start ready for a challenge. It is quite hard to start getting into testing. Expect a challenge, but remember – challenges can be overcome.

I Have Started. Now What?

So you are starting a new component/feature and you want to test the hell out of it, but you are looking at a blinking cursor and not sure what to do from here..

(these are not in any major order, but I have tried to keep it in line with the development “flow”)

Create a New Project to Contain the Testing Code

You don’t want your test code to get mixed up in your production code. The point here is that we are unit testing the code, so we should only ever be accessing it by its public interfaces. Create a new project within the solution. I normally just create a console app called “Test” and save it in the main application directory.

Always Have a Single Test Project for each Unit of Output

For example, a DLL has its own test application, a simple application has its own test application. However a large application should only have a test application for the main application element (since each referenced DLL will have its own test applications elsewhere).

Don’t Put Test Cases in the Main Program.cs File

It’s real easy to dive into the Main method and start writing Debug.Assert’s everywhere, but try not to do this, it can get messy real quick. Create class files for each feature set and then define a static method that the main method can call.

For example:

   1: static void Main(string[] args)
   2: {
   3:     BasicTests.Execute();
   4:     AdvancedTests.Execute();
   5: }

And then in each class, we can start adding our test cases to the Execute method:

   1: static void Execute()
   2: {
   3:     Debug.Assert(Some_Test_Here(), "Some_Test_Here Failed.");
   4:     Debug.Assert(Another_Test_Here(), "Another_Test_Here Failed.");
   5: }

This helps you keep your test cases organised, and the main method much cleaner.

Only Test For What You Expect

I had real problems when I first started because I was constantly sat there trying to figure out every possible problem that could occur and then trying to test for it and fix. This is a quick way to a headache. Testing should be a real YAGNI process. If you know there is a problem, then write a test for it. Otherwise, don’t bother.

Use Long, Descriptive Test Names

This is test code, no-one else (other than perhaps your dev team) will see it, ensure the names of your test cases describe exactly what the test is checking for.

Only Test One Thing

Each test case should only ever test one thing. If you ever find yourself putting “and” in the test case name, you’re doing something wrong.

Once a Bug has been Found, Prove It

Once an issue/bug has been found with some code (either through testing or actual use) before flying off to fix it, first prove it exists by creating a test that puts the code in the same conditions and then fails. You now have proof that:

  1. You have a bug to resolve.
  2. You haven’t solved it yet because the test is failing.

So once you have solved it, the test will pass and you can be confident you have corrected the issue.

This explorative movement can also lead to the discovery of deeper issues, which again, should all be proven by testing for, and then correcting.

Keep Tests Self-Contained

Each test should not rely on the outcome of another, nor need to be run in any specific order. This can be a real challenge when first starting, since it puts a lot of weight on your ability to refactor. This may mean a lot of code duplication to begin with, just DRY them up once you feel confident that you can do so. If not, then leave them “wet”, you’ll get there.

F5! F5! F5!

Run tests all the time. ANY code changes should result in a complete re-run of the full test suite. This includes changes to the test code and/or production code.

Be Efficient

Getting started with testing can and will be costly on the time it takes getting up and running, so remember to work efficiently. If you find yourself writing common code segments (Debug.Assert being a prime example) create code snippets for them! This really helps reduce some of the “cost”.

Where Next?

  • Keep writing more code, testing it as you go. As with all software development Quantity Trumps Quality.
  • There is no “one way”, there is just you and your code, come up with ways to make YOUR code more testable.
  • Look at ways other people are making their code more testable, such as Dependency Injection. Can you use it? Should you?
  • Perhaps look at testing frameworks to see if they can improve your testing process.

Summary

These are the most obvious points that I came across in my adventures. But like yourselves, I am still learning myself. So be sure to either add this feed to your RSS reader to keep track!

Here are some of the more prominent links that I have found useful:

I hope you find this post helpful!

Share:  digg it! del.icio.us Live Technorati Facebook

Monday, 8 September 2008

GTD: Keeping Things Accessible

Following on from my admission that I am a crack GTD addict, here is my second instalment of my getting-started-with-GTD experience.

I started purging my brain of all the clutter that I didn’t need to deal with at the time. My tasks, thoughts, events, information and the like always ended up in one of these locations:

Yes, I know I am a bit of a Google fan boy. I don’t care. They work. They are online. I don’t need to sync anything. Works for me :)

Tasks went straight into RTM, events I needed to be reminded of went straight into Calendar, interesting blog posts for further reading get starred in Reader, good links get saved and tagged in Delicious and any odd bits of knowledge and info went in to Notebook. This meant I was hitting them a lot – especially RTM.

So, I soon found that me needing to keep grabbing the mouse and clicking my shortcut on the Firefox toolbar soon became a bit of a chore (even though this appears like shortcut). Being a keyboard-ninja, I always have my hands on the keys. So I fired up Launchy and began setting up some shortcuts in the Weby plugin (which is included) and began setting up items for:

  • RTM
  • Google Calendar
  • Google Reader
  • Google Reader Search
  • Delicious
  • Delicious Search
  • Google Notebook

On top of this, I also installed the Google Notebook Firefox Plugin so I can add stuff to Notebook directly from the context menu.

Following this, I now have all of my major GTD tools at my fingertips, all accessible within 5 keystrokes (Win+Esc for Launchy, up to three keystrokes for a shortcut). This has REALLY helped me in becoming more productive with the tools, since it really is no longer a “hassle” getting to the items.

Think about what applications/services you use a lot to GTD and stay organised. How accessible are they to you? Does their level of accessibility inhibit you using them efficiently?

Share:  digg it! del.icio.us Live Technorati Facebook

Thursday, 4 September 2008

Twitter Noise and Tweetiquette

I recently had a contact tell me they have ceased to follow me due to the large amount of tech-chatter that I participate in on Twitter. Now, I have no problem with that, they are not a tech-head and I don’t want to pollute her twitter screen with my constant geeky drivel.

But, it did get me thinking, twitter has sort of become an IM service. I find myself often posting extremely uninteresting posts to people (e.g. “thanks!”) as replies. This means that the update will appear on the screens of all who are following me. Sure, I have had no complaints, but it must be quite annoying. I have to say, my screen often gets flooded with similar messages.

I do think this sort of chatter is appropriate for twitter, its fast, its light, its accessible. It’s nice to have the IM-esque use to it, it’s saves me flicking back and forward between applications. Great.

But I do not want to be polluting other peoples space - so, effective immediately, I will most likely start direct messaging those “little replies” that only really mean anything to them.

There is one problem however – Twitter in all their usability wisdom have not added a “mass delete” option for the direct messages. So you have to delete each individual DM one at a time.. FAIL.

I personally will leave them there until they create said feature. Apologies if this annoys people.

What are your thoughts on this?

Update

Following my post of this blog, this sparked some interesting conversation, I think PoppyD hit the nail right on the head with the following tweets:

Very interesting, I know exactly what you mean about 'the big names' here. I unfollowed many, but some (like @jeffpulver) still

manage to interact with their many, many followers. Yet others use their follower power as a chance to get on their soapbox :(

On top of this, many of the “big names” pretty much just spam, they don’t respond to messages/comments etc.  Now this is not to suggest they are bad people, they are probably just incredibly busy. But I find myself asking “do I need this in my Twitter space?” Why the hell do I want to a subscribe to another mailing list of 140-char spam mail?! Well, I don’t! For the most part all the “big names” are doing is regurgitating their RSS feeds, which are all in my Google Reader.

As Poppy quite rightly said, there are also big names that almost use Twitter as a soapbox to air their personal views but don’t respond to criticism/debate. I think this is a common case of “big people with a big mouth”. Which is not on, no one likes criticism. But no-one should not have to have the virtual equivalent of being yelled at by a moron and not having the opportunity to get your own point across. Others, like Robert Scoble often get in to (sometimes heated) debates, and whether right or wrong, they always argue their point with others, and are open to reason. To me, this is exactly what social software is about!

So, I will be slowly un-following some big names. It’s not a personal insult, but I want Twitter to go back to what it used to be. Fast and effective.

Share:  digg it! del.icio.us Live Technorati Facebook

Tuesday, 2 September 2008

GTD: Getting Things Done – My Name is Rob Cooper, and I am a Crack Addict

OK, I have previously identified that I needed to rethink my strategy when it comes to “getting things done” (GTD). But I still felt I was lacking in my productivity. So I got thinking some more, I thought about it when in the shower, I thought about it when washing the dishes, hell I probably dreamt about it. Then it hit me. That was the problem.

Err, What?

I was thinking so much about GTD that I was actually not getting things done! Sounds stupid right? Yeah I know, but it is very easy to fall in to this trap. You know you need to do something, you know you have a lot to do, when the hell do I do it, but do it smartly, where do you begin, so many questions, AHHHHH! Boom. Head explosion.

So now I knew my biggest problem. I wasn’t getting things done. Crap, I am back at square one. But the difference this time is that I knew I was disorganised this is a big step in the admission process. You need to admit that you have a problem and you need to fix it, yeah you are not a crack addict, but you still need to admit it to move on.

Now, I know what my main problem is, I am disorganised. So like the crack addict trying to get off the smack, you need to start taking the baby steps to getting clean more organised. I intend to blog about the various aspects of GTD that I come across, how I apply certain methods and my results. Some may work for you, others may not. But if it gets you thinking, then I will be happy :)

Step 1 – Get it Out Of Your System (The ToDo List)

OK, so the first thing is to get over the “crazies” and stop worrying about our tasks we need to do. Now we could go running back to the smack, but I would strongly not recommend that. Instead, free your mind.. To quote the classic “Platoon” when Junior is talking to Bunny “Free your mind, and your ass will follow”.

Get the tasks out of your mind and into a place where you can review them when you need to.

I know what your thinking, “Well, duh! It’s called a ToDo list Rob and we all have one!”. Sure, but I have had one long before I got to this stage, but it wasn’t helping. Why not? I wasn’t using it [enough].Remember The Milk

I personally use RememberTheMilk (RTM), it’s a fantastic service. Great website, good organisation options and an awesome logo to boot :D I now keep it open all the time. Like most geeks 98% of the time, I am on the computer, so it happily sits there in a browser window until I need it. If I am not able to get to a computer I have the RTM mobile version of the site as my mobiles home page. And I always have that on me. Failing that, a good old pen and paper.

The secret is as soon as you get a task, write it down on your list, then forget about it. Obviously if it’s a really urgent task then prioritise accordingly, but make sure you update any notes on the task(s) you need to stop. This means that your brain is only ever dealing with one task.

Now, the point about updating your notes is very important, especially if you switch tasks a lot. You should be able to pick up your tasks notes and quickly know where you are at with that task. This helps you (because you don’t need to think to much about what’s going on), your superiors (because you can give them task/project updates at the drop of a hat) and above all, your brain because you are keeping information out of your short term memory.

This takes discipline, but after doing it for just a few days, I found I quickly got into the swing of it. I now worry so much less because I know my system is working for me. This is when I then found I could actually start thinking about other areas to look at, one at a time, in baby steps.

Summary

  • Get tasks out of your head and onto a list.
  • Ensure you can get the “status” of a task quickly.
  • Organise tasks in a relevant fashion, use more lists, tagging and search systems (where available).
  • Burden your GTD system more and your brain less.
  • Only focus on one task at a time.

I will post more snippets of my learning’s/methods soon :)

Share:  digg it! del.icio.us Live Technorati Facebook