Lance Wicks
Kiwi,
Judoka,
Geek,
Husband
Daddy!

JudoGeek Blog

Bug squashing and TDD. 

As I progress with my DojoList project I am trying to be a good boy and integrate coding standards (via PHPCodeSniffer ) and also automated testing.

My tetsing is presently using SimpleTest for PHP. As I progress through the project I am trying to be stricter with myself and write more and more tests.

Part of this attempt at discipline is to write tests against my bugs BEFORE I write fixes for them. This is a test Driven Development (TDD) idea, and it is one I think is worth using.

The idea here is that you write a little bit of code that hits your bug, then after you have a test (that fails) you make your fix and re-run the test... and the test should then pass.

One of the benefits of working this way is that you have to isolate the bug so you can write a test for it. This forces you to delve pretty deep into the bug and understand it, before you start trying to fix it at all.

This also leads you to identifying messy bits of your code. Basically, if it's hard to isolate and test your bug, it's probably becuase your code is not abstracted out nicely. Writing tests for bugs can lead you to modify your models/controllers/classes/whatever to make it easier to test just the buggy part of your code.

Writing a test for a bug, also lets you leave an artifact that shows you addressed the issue, in code. So for example you can leave a comment in the test that states what bug you are testing for.
Obviously, it also means that latter on in the codes life, that bug should not creep back in as you test for it everytime.

I have found that writing tests for bugs is helping persuade me to write tests for new pieces of functionality before I code them. In other words writing tests for bugs is a bit of a "gateway drug" to full test driven development (TDD).

I find the urge to write tests first growing the more bugs I start squashing. This is all leading to stronger code. And code I am more comfortable playing with.
You develop a trust in your tests, you know that if you mess something up (and you will), your tests will save you from going on after a mistake.

All in all, writing bugs has been a really positive experience that is leading me towards writing more code in full TDD mode in future.
[ add comment ] ( 1586 views ) permalink
DojoList 0.5.0 

Screen shot 2010-03-26 at 9.47.18 PM

Hi everyone,
so I am really pleased to say that I have completed version 0.5.0 of my little DojoList project. DojoList, for new readers is a web application to maintain a list of Judo Club Dojo locations and information. 0.5.0 is the latest iteration of the development.

Whats in 0.5.0
I have been using PivotalTracker to maintain my list of things to do and so forth. So here is what was in this iteration.
* Modify to RESTful url structure
* ReCaptcha for CRUD operations rather than password access… as option?
* Add ability to edit training sessions. Presently you can only add them on create.
* Ability to upload club badge/logo
* BUG:You can't create a dojo without uploading logo
* git .ignore of index.php

RESTful url structure.
I removed the "admin" interface, and replaced it with a structure where the admin functions (create, edit, delete) are accessed via the main interface. So for example, EDIT is accessed via .../dojo/<dojoname>/edit

reCaptcha
As I have brought the admin functions into the main URL structure and removed the login/logout process (for now), I needed a way to manage changes to Dojo. I decided to include a captcha field, specifically the reCaptcha system which is free and as well as protecting your pages helps digitise documents.

editing training sessons
I did not include this before as it was/is slightly more complicated than the other areas due to the need for multiple session information to be included.But I have now added it; which means all Dojo info is editable now.

Badge upload
I've added basic upload of images into the XML file and display in pages. This took a while as I had to add the upload AND embed it in the XML using base64 encoding. Lastly I display the image inline, which took a bit of extra effort.

** Bug.
The upload initially had a bug that you were forced to upload an image with a new dojo or creation failed.

Ignoring index.php
I keep the api keys the software uses in the index.php file. This is a pain when working on "open source" as I needed to remember to remove the API keys before I commit changes to the repository on GitHub. So I decided to create a index.php.default file, which manually needs to be renamed to index.php upon installation.
I then used .gitignore to ignore the index.php file in my development directory, now I can keep the API keys in there and stop worrying about removing them when I push to GitHub.

SUMMARY and what's next

This is the first iteration I've done this way and I need to more development on the project this way before I decide if I like it. But so far I like it.

The next iteration starts... well now. It has a due date of the 5th of April and will be the 0.6.0 version. The stories I have in the iteration are:
* Ability to upload coach photo
* Format CDATA
* Add center map to postcode ability
* Email notification of changes to dojo listing
* Ability to upload coach photo

You can of course try out the system (and add you Dojo) at www.dojolist.org and see the tracker at http://www.pivotaltracker.com/projects/35696 the source code is freely available at http://github.com/lancew/DojoList .

If you are interested in helping... I am interested in hearing from you!

Lance

[ add comment ] ( 929 views ) permalink related link
Waze... download and install it now! 

Mazdaspeed3-6135

Hi All,

so over the past month or so I have been trying a new iPhone app called Waze, which is the subject of this post. Waze is (to quote the website) "...a social mobile application providing free turn-by-turn navigation based on the live conditions of the road...".

The differences between Waze and say TomTom are considerable, but all starts with the fact that the maps and the traffic reports are created by the userbase, AKA you.

Once you install Waze, you run the app on your phone; be that an iPhone, Android, Windows Mobile or Symbian. When the app is running your GPS position is used to place you on the user generated map. If the street is not on there already, you can add it.

What is really cool, if you get caught in traffic; Waze knows about it and can let everyone else know! When you see a speed camera, accident, police, etc. you can report it yourself and up it pops for everyone to see.

Now, there is more magic to it than that. There is the Twitter integration, Foursquare integration. There is also the points system, which makes driving around to and from work, the shops, whatever like playing Pacman for real.

In short, Waze rocks!

It's very early on too, so I can't wait to see it grow! And here are some of the ideas I reckon might be cool.

More Twitter: At the moment it's one broadcast from Waze to Twitter. It'd be cool if say my @replies and DMs appeared on the screen? Maybe see tweets on your route? I wonder howe many people are tweeting about the traffic?

More Foursquare: It'd be kinda cool to be able to navigate to Foursquare locations. Also, what do you think of the idea of Waze identifying Foursquare locations nearby and asking if you want to check-in?

Open Street Maps: Now, there may be background as to why Waze is not using or contributing to the Open Street Map project, but I can't help but think it'd be a cool collaboration!

Alerts and Actions: I used to have on my Jailbroken iPhone an app called iComing. It alerted me when I reached certain GPS coordinates. That meant things like alarms, sending a text message. It'd be cool it Waze would say text my wife when I hit the motorway turn off for home. Maybe Tweet a message if I am going under 40 MPH on a certain piece of a road, or get near the office.

More Social features: So being able to follow people/friend them. Stuff like that. Ahem... NoseRub... Ahem. ;-)

So there you have it, thats my two cents worth on my favorite application on my mobile at the moment. I love Waze and I reckon it's going to get better and better. I hope so anyway, because to be frank, the actual navigation/routing is pants for me at the present. I've been editing the map to try and make it better... so hopefully as they come online it'll get better. Also not seen any of the automatic route optimisation etc... presumably because at the mo the maps around me are not up to scratch?

But even with those points, I love Waze. So give it a go, it's free and really has potential.

---
Photo by liquoredonlife
[ 1 comment ] ( 1211 views ) permalink
DojoList... Internationalisation and testing added. 

Although time has been short recently, I have started making some changes to my Dojo listing code, which I wanted to add to the blog.

Firstly, I have added some simple internationalisation support.
As of version 0.3.0 simple Internationalisation using Gettext is added. The language support is in the /locale/xx/LC_MESSAGES/ directories, using the standard two letter abbreviations for languages, i.e. en for English, es for Spanish etc. Native speakers can assist the project by editing the messages.po file in the directory. The .po file is then used to create the .mo file.

Basically, I have since gone through most of my views and replaced echo statements with the gettext abbreviation _('........'); statement as below.

<?php echo _(“Home”); ?>

The next step was/is to create tranlation files using:

xgettext ../../../views/*.php

Then run :

msgfmt messages.po -o messages.mo

I then needed to add some simple code to the app to manage which language is displayed. Including the translation is a case of including


// Specify location of translation tables
bindtextdomain (“messages”, “./locale”);

// Choose domain
textdomain (“messages”);


in the main index.php file and also selecting the language using:

<?php
// Set language to Spanish
putenv (“LC_ALL=es”);
?>


This all works pretty smoothly, if the .po file is blanked, then it defaults to the original. So for English, I have not had to add anything. So all I need now is people to translate the text. :-)

Automated testing.
I have added a /tests/ folder to the project and included the simpletest framework to make testing my code simple and easy. So far I have done very little except get it in place and working.

I have started by adding some basic tests to the Dojo model.

My intention is as I progress to write my tests first and then write the code to implement the features I want. It's good practice, but I am lazy and have nt been doing it.

I've just this evening merged the branch I was using to develop the localisation into the master branch on http://github.com/lancew/DojoList

Go take a look at the code there, or see it in action at http://dojolist.org

Lance.
:-)

[ add comment ] ( 553 views ) permalink
Maintaining momentum... 

Hi everyone,
long time no bloggage I know. The bloggage Blockage has been the result of a whole heap of things. Work, Judo, Life all conspiring to keep me away from this blog.

My pal Chris posted recently that he is clesaning up his digital life, I think I could do with doing that... heck doing it with my analog/real life would be good too.

As some of you know, I have been working for a client since October last year, based an hour or so from home, 5 days a week; with increasingly regular overnight trips around the UK. This is due to come to an end in March and it has had me thinking about momentum.

The new client work has been great, good for my business and challenging work. But it has been all consuming, very little time has been left free to me to keep other aspects of my business rolling and also to pursue other things like open source projects.

So with the end of this client work looming, I have the opportunity to look forward and try and set some direction in my commercial and personal life. For example, I have been working on another language version of my PlanetJudo.com website (French this time). Once that goes live, I want to finish the PlanetJudo iPhone app I have had a varying levels of completeness for months and push it to the Appstore.

I also want to bring the DojoList project to a releasable level. I have started on rudimentary multi-lingual support. Which has been helpful as the next step in PlanetJudo's future is a big refactoring to incorporate languages better and be a single application with language support. Rather than 3 copies of the same app customised to each language as it is now.

Also on the list is a new car (or two), more podcasting, more coaching, more clients. Too much to handle I suspect, so some good planning is required. I am also wanting to do a Judo research project for the next IAJR symposium (and potentially preparing and poster fo the EJU research symposium that may take place in April). I also need to put some time and energy into JudoSpace, the training company I am a director in.

Phew...

And all through this the big issue that ove rthe last few months I have totally lost momentum on pretty much everything except this main client I have.

So the big question/goal/challenge for the next period is this, how do I maintain/develop momentum when faced by the real life day-to-day issues of things to do.

My hope is that once I get free of this project I'll be able to set things up to allow me to do what needs doing whilst also maintaining momentum on my projects.

Any suggestions or experiences in this area would really help me understand the problem better and help guide how I tackle it all. So please do email or comment.

Lance.

p.s. Now that this project is coming to an end, I'm looking for projects to work on. Preferably in Hampshire, but as the past few months have proven, I can cope with commuting (to a degree). Web stuff, Server stuff, Coaching stuff, please let me know.
[ add comment ] ( 8671 views ) permalink

<<First <Back | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Next> Last>>