Sunday, 11 October 2009

Cool Podcasts

I haven't fallen off the blogging planet just been busy enjoying life. Family's great, friends' great, work's great (although challenging). So I've been looking for some more cool podcasts to listen to while commuting to work or performing repetitious tasks. I find I can't listen to stuff while concentrating but if something is a little monotonous I enjoy a good podcast (when not listening to classic hair metal!). Here are some of my favourite podcasts:
  • the Grails Podcast - my favourite all time podcast. Glen and Sven bring cool Groovy and Grails news whilst at the same time remaining positive and funny. I would listen to this even if I wasn't into Grails.
  • Software Engineering Podcast - this is a somewhat more sombre podcast but very educational. This is not so much a news podcast as teaching podcast.
  • Hak5 - This is a vidcast and covers a bunch of different stuff. Its got a little bit of product promotion and sponsorhip recognition but nothing that seems to compromise its integrity. Also really entertaining with a great vibe between the presenters.
  • Elegant Code Cast - I wasn't sure about this one. Its not java orientated and I have zeroo .net and c# experience but interestingly they cover some good topics. I've only listened to a couple of these but I'm going to stay on it for a bit longer.
  • Network Security Podcast - Stock standard security podcast (and I've listened to a few) and pretty informative. I like this more than Security Now (too much advertising in that one).
I look for casts that are interesting, short (ideally 30-40 mins) and entertaining. Got any suggestions? Let me know!

Saturday, 11 July 2009

When does it end?

So its been awhile since I last blogged. Things have been going swimmingly with the squashLadder with basic functionality built and I find myself questioning when I should call it finished. I have a number of other ideas for interesting projects so when do I walk away from this one? I find these phases of a project difficult to get past. The app is pretty much at a 1.0 stage and is usable, indeed is being used to record our work squash games so is it time to move on?

Normally I could seek counsel and direction from the great Grails sage but alas he's on sabbatical. Therefore prior to sitting at the keyboard tonight, I tried to channel the Kenobi like advice that I thought he may have provided and this is what I came up with.

The original purpose of the app was just to learn not necessarily to build a plain old app. Rather than just being satisfied with the mediocre app, I should push the boundaries and do the extra stuff that make the learning worthwhile. Here's a list of stuff that would be cool:
  • add line chart to front page showing win percentage trends for each player
  • add some sort of cool fade in transition on the stats page to cycle between a players matches & wins / trending vs players and form-o-meter
  • remember me functionality
  • ability to add groups of games (via checkboxes) rather than having to individually enter each game.
I guess building another app would reinforce some of the things that I've learned so far but the ladder has been such a great vehicle for learning that I should continue with it.

If you've got suggestions for features that you think would be cool, please let me know.

Sunday, 7 June 2009

JSecurity

In a moment of madness I suggested to some work colleagues that they could check out the 0.1 version of the squash ladder app. Naturally it took them no time at all to crash my app server (with a divide by zero error). I'd been meaning to add some security to it and this forced my hand. There seem to be a few options to securing your grails app:

  • authentication plugin

  • jsecurity

  • spring security

  • and simply building your own

  • I pondered this on Twitter and Tomas Lin responded giving me an order of simplest to most complex (this is the order of the list above, removing the final option of course). I decided to go with JSecurity although it was possibly a bit of overkill for my pretty basic app.

    Installing the plugin was totally simple, grails install-plugin jsecurity. I decided against the quick-start option as I was following the example in TDGTG. I also used this Glen Smith's article as I'd incorporated basic login into my existing classes. The whole thing was completed in a couple of days (ok so I'm pretty slow when I do stuff. Most moderately experienced people would knock this over in hours).

    The big lesson out of this was testing. As much as believe the whole test driven development philosophy I haven't followed it this time. I really need to spend more time testing but Grails is just so easy to produce stuff that I get carried away. Anyway I've unleashed the colleagues so we'll see what they come up with.

    My next step is to add some more Google charts action to show off the stats.

Sunday, 31 May 2009

Enter the Glassfish

Okay I didn't want to admit it but the whole Grails/JDO thing turned out to be a pain. The Google hosting plan sounded awesome but what I found was that trying to recode my all ready underdone project was an exercise in futility. Therefore I had to think about other hosting solutions. I thought briefly about Grails Podcast sponsor Morph Labs only to find out that free developer accounts had just been discontinued. Really the only feasible solution was to host it myself.

I had previously set up dynamic dns server as my ISP doesn't have static ip's (unless you pay more of course), so only had to think about an App Server. Based on a friend's experiences and recommendation I decided to give Glassfish a try. Given the early adopter issues I had with Google App Engine I chose V2.1 over the V3 prelude (what's a prelude anyway?).

Set up was relatively easy as there are plenty of guides on the web. After grails war I was away. There were a couple of things that needed addressing though:
  • url contained port number
  • only using hsql file based db
The first issue was addressed with the virtual server in my router by changing all incoming port 80 requests to 8080 for the app server. The second was a little trickier. If I changed the db to mysql or postgresql or whatever, I didn't want to store the db username and password in the datasources config file of my project because being open sources any one could access it. Using advice from the great grails sage I've used a jndi datasource and all is good. Setting this up was also fairly straight forward and all is working well.

Whilst I would like to go back to GAE at some stage, I have definitely learned quite a bit from having my own app server and think that until the project is completely finished I'll keep with Glassfish. After that maybe I look at porting it over again. Next big thing for this app will be security. At this point I'm thinking of using the JSecurity plugin so will let you know how it all goes.

Wednesday, 20 May 2009

My first google app-engine grails app

Free hosting appeals and you can't beat Google's hardware firepower so Google's App Engine sounds like a great hosting solution. The thing is, now that app-engine supports Java would it do the job for my grails app?
This question was basically answered with the release of grails 1.1.1 which includes support for an app-engine plugin. I decided to give it a try with the squash ladder app as it currently stands.
The first issue I found was that my current project name had already been taken or was not suitable. I probably could have just changed the config file in my current project but I decided to create a new app and if all turned out to be easy, I'd be able to paste in my current code. However all was not easy. I tried following Graeme Rocher's screencast but got errors when trying to generate controllers and views.

This bug is described in the comments on the screencast page and in a nutshell, you need to reinstall the hibernate plugin, generate-all, then uninstall the hibernate plug in again. Its a only a minor hiccup and once you're done it pretty much works as described.

So now I've got a shell of an app with CRUD, hosted and using JDO instead of hibernate. Life is looking pretty sweet. Graeme's comments indicate that GORM is not supported so far, so it will be interesting to see how the rest of my hibernate-luvin code goes. The app is here and I'll post the progress of translating the current code to Google also. Exciting times ahead!

Tuesday, 5 May 2009

Solution for transient problem

After much head scratching and reference searching I've come up with a solution to the previously mentioned transient problem. Basically I've changed the list action in the Player controller to:
- check to see if the user is trying to sort by percentage,
- if so a closure sorts based on the getPercentage() method.
- then if the order was supposed to be descending, we call reverse on the list.

Here's the list action code:

def list = { params.max = Math.min( params.max ? params.max.toInteger() : 10, 100)

if(params.sort=="percentage"){
def players = Player.list().sort {player ->
player.getPercentage()
}
if(params.order=="desc"){
println params.order
players = players.reverse()
}
return [ playerInstanceList: players, playerInstanceTotal: Player.count() ]
}
else{
return [ playerInstanceList: Player.list(params), playerInstanceTotal: Player.count() ]
}
}


Quick and dirty tests look good so far. I'm sure there's probably a more elegant solution out there, if so let me know.

Sunday, 3 May 2009

Tricky transient problem

Following on with squash ladder project, I've come across a particularly patience ending problem. I need to display a view that contains a sortable column based on a transient property. My ladder needs to be sorted by winning percentage and this value is transient (calculated and not persisted). A google search shows me a few different posts but nothing that I could get working. Ideally I want the user to be able to customise their view by sorting the columns so in the interests of getting it working I've persisted the winning percentage value.

For this project the additional database isn't going to be particularly taxed but in the interest of learning there must be a grails solution to this. I'll post any solution if I find one, but if you've got a solution let me know. I'm off to cruise Nabble ...