Archive for the ‘Coding’ Category
New Sourceforge Design
Wow, isn’t the new SourceForge style absolutely awful?
Fixing the little things.
When your developing, enhancing, evolving your software you will introduce bugs which range from trivial UI issues to “Show Stopping” issue in business logic that will drive your customers away.
Its pretty easy to prioritize these bugs as tasks for your development team by making the “Show Stoppers” #1 priority and so on… and this list of priorities is often geared around the customer, we make sure the issues that the customer will react to the most are sorted out first and then we get to the other “trivial” issues later (if ever).
While this method of prioritization works well in theory I have observed that developers who are not allowed to fix bugs that annoy them or are “easy” to fix, often loose motivation and interest in fixing those bugs that are not so easy to fix.
I have myself worked on projects where the PM has taken exception to me spending an hour to fix and test a bug because I felt that it was worth doing even thought the “Plan” didn’t express this.
Its so important to let your development team cherry pick issues to fix as well as prioritizing the “Show Stoppers”.

Why?
Developers love marking tasks as “Dev Complete”, it gives us a sense of achievement that motivates us to crack on with the next task at hand.
“Wasting” (if your a PM) an hour on a task that isn’t the most pressing one at the time can have a profound impact on your teams productivity, letting the developers mould the shape of the product by picking the issues, tasks to work on gives them a sense of ownership which brings with it a sense of determination to deliver.
I liken this to the Broken Window (Tip 4) theory expressed in The Pragmatic Programmer by Andrew Hunt and David Thomas.
Profound #1
An Investment in knowledge always pays the best interest.
Benjamin Franklin
Daily Dose #4
Bourbon Creams and Bananas are not a balanced diet.
Phusion Passenger on Amazon EC2
Some useful stuff relating to Phusion Passenger (mod_rails) on Amazons Elastic Computing Cloud.
Moving from Java to C#
A senior ThoughtWorker talks about his first C# project 10 years after he first tasted the Java bean.
IPhone GUI PSD
Some photoshop goodies for mocking up IPhone UI’s.
Exception Notifier in Rails 2.1
If you have recenlty or are about to Upgrade an existing Rails application to Rails 2.1 (and why wouldn’t you), be aware that your implementation of Exception Notifier might not work due to a scope change in Rails where:
@controller.filter_parameters
Is now protected, therefore the code in Exception Notifier that called it needs to be change as follows :
1 2 | #exclude_raw_post_parameters? ? @controller.filter_parameters(parameters) : parameters exclude_raw_post_parameters? ? @controller.send!(:filter_parameters, parameters) : parameters |
Utilizing the send method allows you to call the protected method.
Fortunately the Exception Notifier plugin on GitHut has already been updated to accommodate this fix and can be installed by :
1 | ./script/plugin install git://github.com/rails/exception_notification.git |
NOTE
Exception Notifier (like most plugins) comes with a suite of tests that you should run as part of your build or at the very least whenever you change something as fundamental as the Rails version your using… BTW I did neither of these things and found out the hard way :-/
Catch-All routes in Rails
Sometimes you need a catch-all route in rails to support dynamic applications like Content Management Systems, where all requests that are not matched by an existing route get passed to a controller who can deal with the request.
Add the following to the end of your routes.rb :
map.with_options(:controller => ‘page_engine’) do |site|
site.connect ‘*url’, :action => ’show_page’
end
If that’s your last route, it means that anything that isn’t recognised by any of the other routes will get routed to that controller/action (page_engine/show_page). It shouldn’t interfere with images/assets because they are served with higher priority than Rails routes. It lets you have any number of forward-slashes.
So if you hit your site with the following URL:
http://localhost:3000/we/really/hate/wcf
The request will be routed to the show_page action in the page_engine controller where you can then access the actual url elements with :
1 2 | path = request.path # '/we/really/hate/wcf' path_elements = request.path.split('/') # ['', 'we', 'really', 'hate', 'wcf'] |
While this isn’t the type of thing you would do on many Rails projects you certainly will find this useful for projects that have an element of dynamic routing that goes beyond the RESTful style that rails implements, and its especially useful for implementing Content Management Systems.
Memcached on Windows
Last time I tried to do MemCache on windows I gave up, as getting MemCache to work on Windows was seriously difficult.
Well this is all a thing of the past due to some fine work from Kenneth Dalgleish who has created a Win32 port - Top Man
Installation
Download the memcache port from http://www.splinedancer.com/memcached-win32/
Extract the download to your filesystsm (say c:\memcached)
Create a service using the command : c:\memcached\memcached.exe -d install
Start the server using the command : c:\memcached\memcached.exe -d start (or using the services management console)
Thats it! by default it listens on port 11211
Rails 2.1 makes using memcache really easy and having this option on Windows is a real shot in the arm for Enterprises who are looking to host Rails apps on Windows.
Using jQuery in Rails apps
jQuery is an alternative to the Prototype JavaScript library that is gaining some real traction these days.
jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. jQuery is designed to change the way that you write JavaScript.
jQuery also sports an elegant model of method chaining where almost all methods return an instance of the object they are called on, this means you do do stuff like:
$("p.surprise").addClass("ohmy").show("slow");
The only problem is I love using Rails which has many helper methods that make using Ajax really easy which use the Prototype JS library, so ncluding jQuery as well as Prototype is not only a pain it also means i’m doubling the amount of javascript i ship with each page.
Fortunatly the problem has been solved via a cool rails plugin called jrails.
jrails is easy to install (script/plugin install http://ennerchi.googlecode.com/svn/trunk/plugins/jrails) and replaces all the calls to Prototype with calls to jQeury allowing you to remove prototype from your application without loosing any of the rails magic.
Productivity Tip
This is less of a tip and more a of my own metaphorical “Kit up the Back Side” that happened to me a few weeks ago.
While looking for some software to audit the applications i had on my Mac came across Slie.
Now slife doesn’t audit apps it actually monitors and records the activity of applications that you use.
What makes slife so useful is that it renders the data about your application usage in a timeline representing the day, so you get an idea of which application consumed most of your time.

My expectation of the slife results for a common day would be some email and browser activity in the morning followed my some hard core TextMate activity up until lunch where email, soduko and safari would be used, come the afternoon another good block of TextMate, sprinkle a bit of NetNewsWirs across the entire day and there you go, another productive day from me
Well this is all good an well but the reality is somewhat different, the results actually show that i spend much more time in mail and safari and a hell of a let less time in TextMate, for me this is a real kick up the back side! I value my time and investing so much of it in “Surfing” or “Emailing Friends” is not a good us of my valuable time.
I now run slife all the time, and review my own activity at least on day a week.
Net result : I now spend more time “working” so i can get my task done sooner… which gives me more time to surf
Estimating - I love estimating.
Estimating is one of those tasks that really takes it out of the whole team, hours or even days of reviewing stories and estimating the effort is hard work.
The temptation is to crack on and keep going until the task is done however I can’t stress enough the importance of taking time away from this process to recharge and re-engage with the subject mater.
Some techniques for making the process less onerous (if thats possible):
Story Rotation
Often teams will follow a story list as it define by the BA, which in my opinion can lead to less informed estimates, having discussed the attributes of one story only to be presented with another similar story can often lead to dismissive estimations where in isolation the story may reveal more detail.
Take Breaks
Accept that a fresh mind is better at dealing with problems, taking a break is one of the most productive things you can do.
Give everyone a stage to express their opinion
So often the dev lead will take up most of the air space while more “junior” members of a team will sit nodding (or nodding off). Give your whole team a chance to engage in this process after all you will expect them to work in this project right?
Have Fun
Enjoy the process by making it fun! Use novel gestures for estimating or high five when you all agree, whatever it is you guys do that is fun, do it and do it more often, having a laugh will make the most onerous of tasks less so.
Estimating has to be one of the tasks i “enjoy” the least however, its value is without question.
