888888.888888.88""Yb..dP"Yb..8888b..Yb..dP.88b.88....db....8b....d8.88..dP""b8..dP"Y8
88__...88__...88__dP.dP...Yb..8I..Yb.YbdP..88Yb88...dPYb...88b..d88.88.dP...`".`Ybo."
88""...88""...88"Yb..Yb...dP..8I..dY..8P...88.Y88..dP__Yb..88YbdP88.88.Yb......o.`Y8b
88.....888888.88..Yb..YbodP..8888Y"..dP....88..Y8.dP""""Yb.88.YY.88.88..YboodP.8bodP'


88b.88.888888.888888.Yb........dP.dP"Yb..88""Yb.88..dP
88Yb88.88__.....88....Yb..db..dP.dP...Yb.88__dP.88odP.
88.Y88.88"".....88.....YbdPYbdP..Yb...dP.88"Yb..88"Yb.
88..Y8.888888...88......YP..YP....YbodP..88..Yb.88..Yb

May 5, 2008

Jonathan Snook has written a post about the process that freelance programmers follow. I think it applies quite strongly to plugin writers many of whom are hobbyists like myself.

The post focusses on quite an old article from Fast Company about the engineers that produced the computer code for the space shuttle programme.

The article has inspired me to improve the way I work.

I, like a lot of plugin writers, have never had any formal instruction in programming; I have pieced together what I know, somewhat happazardly, as and when I needed it. This often means that there are patterns and practices that are obvious to some that simply don’t occur to me, and therefore my code tends to be produced in a rather trial and error way.

The first part of the process is to properly plan the plugin.

In business when you start a project you specify it great detail. You know what you want into each process and out again. But with a hobby project it is usually a case of starting with a small kernel of an idea and then building on it as each part seems to work.

I have gotten used to specifying things in my head and then writing to see how they work and whether I should keep working. If the basic part works I look at what else I should add, and then bold on whatever else comes to mind.

My goal from now on is to formally specify the features for each version that I write, and then write with that aim in mind. Only when that is complete and works as intended will I add any new features.

Generally, my testing consists of using the plugin and trying to replicate the scenarios that it was created for.

My intention from now on is to use unit testing to check that each part operates properly before the plugin gets anywhere near WordPress itself.

I made my first attempt at unit testing this weekend. I was aware that the counter on my anit-spam plugin was counting comments it shouldn’t so I downloaded the Simple Test unit testing framework and tested the crucial counter section.

Just by going through the process I managed to make the code easier to work with and, hopefully, a little better, but I also confirmed that it was actually working as intended. The problem was that the inputs into the function were different under certain circumstances.

Testing against the revised inputs showed me exactly where the problem lay and I was able to resolve it.

I have always struggled with the bounderies between art and science when it comes to programming. While I want to work like a scientist, all too often I end up working like a artist. Hopefully I can start to change that now.

Fun With Theme Widgets
Funy photo widget?
24 comments
page 867
Post Image The Easy Peasy Way
Wordpress attach image to multiple posts?
26 comments
page 1065
Using Your Own Url Shortener
Wordpress clear rewrite rules?
4 comments
page 1190
Quick N Dirty Category Redirection
Wordpress redirect category?
no comment
page 133
Html 5 Gallery
Themeatic html5?
6 comments
page 1305
Premium Ithemes Review Photo Gallery
Ithemes review?
4 comments
page 226
Updating Code Snippets Here
Wordpress fun plugins?
one comment
page 1338
Updating Code Snippets Here
Wordpress fun?
one comment
page 1338
Theming Habari Vs Wordpress
How to design a habari theme?
13 comments
page 440
Why I Ditched Disqus
Disqus email?
5 comments
page 1175
Post Image The Easy Peasy Way
Wordpress first image?
26 comments
page 1065
Quick N Dirty Admin Login Screen
login screen using css?
no comment
page 128
Html 5 Gallery
Picture gallery html5?
6 comments
page 1305
Html 5 Gallery
Html 5 photo gallery?
6 comments
page 1305
Post Image The Easy Peasy Way
Wordpress first image gallery?
26 comments
page 1065
Post Image The Easy Peasy Way
Resizing images in thecontent?
26 comments
page 1065
Post Image The Easy Peasy Way
Inserting an image url in comments?
26 comments
page 1065
Post Image The Easy Peasy Way
Wp attachment functions?
26 comments
page 1065
Dont Mess With My Toot Toot
Wordpress custom content?
16 comments
page 599
Using Your Own Url Shortener
String shortner?
4 comments
page 1190
Quick N Dirty Admin Login Screen
My admin login page?
no comment
page 128
Using Your Own Url Shortener
How to build a shortner link?
4 comments
page 1190
Post Image The Easy Peasy Way
Get post attacments?
26 comments
page 1065
Theming Habari Vs Wordpress
Habari vs wordpress?
13 comments
page 440
Are Child Themes The Best Option
Wp child themes?
15 comments
page 1262
Upload From Url
Upload to url?
6 comments
page 326
Silence Is Golden
Silence is golden wordpress?
3 comments
page 213
How To Add Sidebars To A Theme
Html hot add a side bar?
10 comments
page 1053
How To Add Sidebars To A Theme
How to add picture to the wordpress sidebar on sidebarphp?
10 comments
page 1053
Fun With Sidebar Tabs Styling
Position of the tabs thematic?
2 comments
page 336
Using Your Own Url Shortener
Short url?
4 comments
page 1190
Why I Ditched Disqus
Styling disqus widgets?
5 comments
page 1175
Wordpress 25 Exif Fields
Wordpress exif?
12 comments
page 230
  1 query every 1765 seconds, updated 1 seconds ago.
Monday, 3pm
 __
(__)
   `

 Andrew Rickmann

I think there is a lot of testing done as part of the core development. My experience is that the core is rarely the source of a problem which is why I want to improve my plugin code by taking a more structured approach.

I totally agree about a good night’s sleep and even leaving the office at 5 regardless. I think it provides a lot of structure that then leads on to other areas, like the code itself.

Monday, 3pm
 __
(__)
   `

 Austin

Thanks for linking to Snook’s article. I think you’re right to point to unit testing as a good way to avoid many coding problems, and it’s something I hope to see become a part of core WordPress development.

Another thing that really makes a difference to me is just touched on by the NASA article: getting a full night’s sleep. It’s amazing how the simplest problems seem unnecessarily mind-boggling when I’m propped up by a few cups of coffee.

Unfortunately, unit testing and sleep are among the first things abandoned with looming deadlines.