Top x Coding Issues

My experience in Software Engineering has shown me that a certain breed of bugs keeps re-occurring. The following is my list of the biggest (needless) causes of bugs:
1. Uninitialized variables.
2. Poorly named variables and functions.
3. Multiple function exit points (i.e. multiple returns).
4. Not checking return codes.
5. Not checking before de-referencing.
6. Not verifying target buffer lengths before using them.

I’ve been involved in numerous discussions about what should be included in a Code Standards Checklist, and in my opinion, this list is pretty much all you need. Anything more and people ignore it anyway.

Posted in Development | Tagged | Leave a comment

How to Fix a Sony Remote – RM-ED035

Problem

My youngest son (12 months) decided our TV remote would be good to chew on – he is really rather like a dog at the moment!

He didn’t have it for too long, but managed to do enough damage that the remote was repeatedly sending button presses to the TV. :-(

I tried the usual tricks: taking the batteries out and putting them back, using a hairdryer to try and get rid of moisture, and mashing the buttons. Nothing worked.

Next, a quick check on eBay suggested I could get a replacement for £15, so not too bad, but worth me having a go at fixing it.

A search on Google didn’t turn up anything useful to help fix it, so after a few experiments, I managed to take it to pieces, and thought I should post here in case anyone else has the same problem and wanted some help.

How To

First, you need to get the back cover off. It slides up, so you can replace the batteries, but at this point it isn’t obvious how to remove it. There are two ways; you can either use a flat metal blade (I used a table knife, but you may wish to use something safer!) and insert into the seam between the back cover and the main body and then slide it up and down until you pop open the catches, or, the better way, is to half slide up the back cover and you’ll notice little grooves that it slots into to help you get it off.

Next, remove the six little screws. Even with these removed, it is still locked together because of internal catches. I couldn’t find a simple way to get this off, so had to use the same flat blade trick as before.

After you’ve got this apart, you can clean the rubber keys and the contact board, and hopefully this will fix it for you. Then, just put it back together and you are done.

Hope this helps.

Posted in Development | 4 Comments

Rails and MySQL

Jeez, it gets worse.

I finally managed to get things moving my installing RVM and Homebrew. From this I installed Ruby 1.9.2, Rails 3.0.7, and MySQL 0.3.2. Unfortunately, if you use MySQL 0.3.2, you need to use Rails >=3.1. So, I downgraded to MySQL 0.2.7.

Then, I got some annoying MySQL connection error.

Finally, after three evenings of trying to resolve the error, I’ve have removed RVM, installed the MySQL2 gem into my system and configured the link to the MySQL lib, and finally, after a reboot, I’ve got it working.

Phew. I’ve not had this much hassle since I tried to install OpenNAS on my Linux box.

Posted in Development | Leave a comment

Ruby and Rails and MySQL for Mac (Snow Leopard)

Whilst we are living in Mountain View, we thought we’d join the library. It is pretty impressive, and the kids section is bigger than my entire local library in the UK (in fact, my closest UK library has just been shut down due to budget cuts!).

In most of the libraries I’ve been to in the UK, they usually have about 3 computer books:
* Windows XP for Dummies
* How to use an iPod
* C++ in 24 Hours

However, the Mountain View library has a few hundred computer books. It is pretty impressive.

Whilst we were there I spotted a few books on Ruby and Rails, given I’m interested in learning new things (and have a history of using Python), I thought I’d give it a go. I know I’m a little late to the party, but I’d rather be playing with something like this than watching some rubbish on the TV.

Thankfully, Ruby, Gems, and Rails are all pre-installed on my Mac. Unfortunately though, the book I’ve borrowed suggests I use MySQL as the DB, and MySQL isn’t preinstalled.

Whilst the installer was pretty simple, getting it to work with Rails has been rather more troublesome. I thought I’d post about how I’d managed to do it, but I’m still not there – and I’ve spent the past 2 hours trying to get it to work. :-(

I guess that is the problem with computer books, they are out of date as soon as they are written. Maybe the UK library model works best ;-) .

Posted in Coding, Development | Leave a comment

OneNote Journal

I’ve been using OneNote for about a year now, and am loving (almost) every minute.  There are a few annoying areas (especially the lack, as far as I can tell, of the picture border tools you get in Word/Outlook/…), but I use it every day to collect information and help we work through you tasks.

One of the tools that has been recommended to me by my friends is OneNote Journal.  The idea of this is that it can easily create a new day page in OneNote, so that you can keep a daily journal, without having to manually create as page/section/section group with the date.  Unfortunately the tool that they gave me only worked on OneNote 2007, and since I use OneNote 2010, this was no use.

So, about six months ago I created my own OneNote Journal tool, this time for OneNote 2010.  It won’t work on an previous version of OneNote, but seems to work fine for OneNote 2010.

The tool sits in your Notification Area (aka System Tray), from which there is a menu to change the date format, and also to create an entry.  As well as this, you can use the Windows+J to create a new entry for today.  If one already exists, then it should automatically bring that page to the foreground.  The tool should automatically create the Year, and Month sections for you – to keep it nicely organized.


If you want to download the tool, it is available here:
http://dl.dropbox.com/u/10638488/OneNoteJournal%20v1.2.zip

Note: Before you use this, you will need to create a notebook in OneNote called ‘Journal’.

Disclaimer: Make sure you backup your OneNote journals before you use this tool.  Whilst I’ve not had any problems, it is better to be safe.  And if something does go wrong, I will be unable to help.

Posted in Development | 11 Comments

Aperture Plugin – Post #2

Ok, so after a fair amount of hassle, I’ve determined that it is not possible to create a new Aperture Export Plugin from the template, if, you are using XCode 4.

The ‘trick’, if you can call it that, is to use XCode 3 to create the template, and then use XCode 4 from that point onwards.

If you need a new named template creating, let me know and I can create one for you using my XCode 3 instance for you to use in XCode 4.

Posted in Development | 3 Comments

Aperture Plugin Development

Given I’ve just bought Aperture 3 (from AppStore), I thought I’d have a go a developing an export plugin.

I belong to a photo blog site called www.blipfoto.com, and whilst they have an API, so far nobody has created an Aperture Plugin for it.

So far it hasn’t gone too smoothly, so I thought I’d create a post in the hope that if someone else has problems, they will find this and it’ll help them.

Firstly, download the Aperture 2.1 SDK from Apple.  Then find the plugin examples (‘/Developer/Examples/Aperture’).  When I opened the Export example, and tried to build it, I got the following error:
* error: There is no SDK with the name or path ‘/Developer/SDKs/MacOSX10.4u.sdk’

A quick check on the web helped me to remove this problem (goto to your build settings, search for ’10.4′, and change the build setting to target the latest OS).

Next, you’ll probably get another error:
* ‘PluginManager/PROAPIAccessing.h’ no such file or directory.

This is a little bit of a pain to resolve, but basically involves two steps:
* Move the old PluginManager folder out of the way
* Install PluginManager again (install the FxPluginSDK, which will re-create the PluginManager folder)

Hope this helps – and I’ll let you know how I get on.

Posted in Development | 3 Comments

Outcome Based Design

When it comes to design, especially in Software Development, there are a multitude of opinions:

  • Upfront design;
  • Iterative design;
  • Retrospective design, and;
  • No design phase at all.

I think it is fair to say that each option has validity, but, I think it is important to identify that each approach has a direct mapping to the desired outcome. For example, I think we can all agree that when it comes to writing the software to handle Emergency phone calls, we’d all hope that a significant amount of forethought, analysis and refinement had taken place before the construction phase began. In this instance the desired outcome is a highly resilient, reliable and safe solution.

Alternatively, when we are fact-finding and information gathering, it would be counter-intuitive to try to define the design, when we haven’t got sufficient information to determine the effectiveness of a proposed design. In this instance, the desired outcome is to increase our knowledge and experience, which we will hopefully use to positively influence future activities.

I think a good analogy is with clothing. When creating a new clothing line, you first want to define your goal (i.e. winter, summer, smart, casual, etc.). Following this will be a period of un-restricted ideas and free-flowing investigations – probably working directly with different materials to see how they perform. With more knowledge and understanding the designer would create a blueprint, which is then handed off to the manufacturer – at this point very specific instructions and measurements are required in-order to produce the desired garments.

Over the lifetime of the project, you’d probably say that it followed an iterative design approach – but actually, each phase of the project has a different design approach, based on the desired outcome for that phase.

I think the same is true for Software Engineering.

Posted in Development | Leave a comment

Design Club

The first rule of design club is … designing is not about writing documents.
The second rule of design club is … designing is not about writing documents.

If you are trying to design something at the same time as you are writing a document then it is fairly obvious that you can not be concentrating fully on either thing. Therefore, use whatever tools allow you to be creative during the design phase, but make sure you capture that information (in whatever format is appropriate) for the next phase of design.

Contrary to what seems to happen, design is iterative, and you need to make sure to that refine the design, the repository for that design work is flexible. People often talk about the importance of flexibility in code, but the same applies to all aspects of Software Engineering.

Posted in Development | Tagged | Leave a comment

Creativity

The essential ingredient for creativity, is the freedom to think. Without this, it is almost impossible to generate new ideas.

Unfortunately, quite often you need to be creative when you are under the most pressure to deliver.

If you get caught in this situation, the best thing to do it take some time out, and think.

Posted in Development | Leave a comment