Sunday 1 November 2009

Enter the Koala

I've been wanting to get away from Apple for a while. Now don't get me wrong I think their stuff is super cool but the idea of complete freedom really appeals. I've a household that has 2 iMacs, an old powerbook and a macbook. So the quest for freedom means Linux and I've chosen Ubuntu for no reason in particular. My personal machine is used for development stuff (Netbeans, Eclipse, Textmate) and the usual web surfing stuff. I also keep my music on this machine and sync it to my iPhone.
Now I tried to switch away to Interpid Ibex but found a number of problems:
  1. My Microshaft Bluetooth Mouse wouldn't pair
  2. Sound quality was dodgy
  3. Couldn't drive my external 24 inch monitor (deal breaker)
After getting annoyed with some Snow Leopard problems (trouble loading images from sites in 10.6 but these work fine in 10.5), I decided to try again with the latest Ubuntu, Karmic Koala.

My initial findings were really positive, the install process was easy as always, and relatively quick even compared to Snow Leopard. The bluetooth mouse paired without incident and I was really impressed with the look and feel. The number of free software packages is outstanding and really I haven't been able to find anything that I'm missing.

However, my poor old Macbook (mid 2007 model) can't push the pixels required for the external monitor even when turning off the native display. This is a blocker for me as I need the extra screen real estate with my failing eyesight. Another small issue is that while sound plays out of the inbuilt speakers, it wouldn't play from a headphones or line out to external speakers. I'm sure with a little digging I could find a solution for that but without the graphical power to use my extra monitor I'm going to have to go back to Apple.

This being said I feel that Karmic Koala is totally awesome and I'd happily move to it if my hardware would do the job. Given PC prices are cheap in Oz at the moment, I might consider getting a box and using that as my main machine. (PS I blogged this from Karmic and felt totally free while doing it).

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 ...

Wednesday 29 April 2009

Quick Project

During conversation at work today we joked about the need for web app to track lunchtime squash results. I've decided to give this a go (using Google App Engine). I spent 5 minutes thinking about the relationships required and the basic app was created in less time than it takes to start a portal server.

So far I've created 2 domain classes (Player and Game). Basically we want to record the date a game was played, who won and who lost. This was pretty much done with just scaffolding. Ideally we'd like to keep a ladder perhaps sorted by winning percentage. With only 10 minutes of work the basics are there. I'll need to manipulate the views so that dates are more concise and links are by name rather than id. Also I'll need to create a couple of more views (such as the ladder) and a validator to ensure that the winner can't also be the loser!

Not sure how well Google App Engine copes with Grails yet but I believe there are a couple of tutorials out there. This is a pretty simple app so not anticipating any big issues. I'll post progress...

Monday 27 April 2009

The next big thing...

Ok so I'm still working on the grails comp but I've begun to get excited about the next project.. a football tipping site. I know there are heaps of them around the web all ready but I want to make my own with the features that my friends and family want. I think it will be an excellent learning vehicle. And that brings me to my dilemma... what do I use to build it?

Grails is very exciting and produces results fast but I'm a java developer by day and really could use the extra experience developing with Spring and Hibernate. I feel like I'm missing out because at work we use Java 1.4 and therefore I haven't used annotations, enums or any of the new post 1.4 goodness. This might be a good opportunity.

On the other hand, should I give Ruby a go? I've messed with Python before and enjoyed it but haven't touched Django or TurboGears. Dynamic or static language? Which offers the best learning experience? My goal here is to learn and develop my overall programming skills. I have no time limit although before next footy season starts would be good (March 2010).
Do I continue with Grails to cement what I've learned all ready? What would you do? Continue with Grails, go back to Java or try something new? I'm interested in any and all opinions.

Tuesday 21 April 2009

On to CSS

After going all "scorched earth" on the grails comp and basically beginning again from scratch, I've managed to get through the many to many problem. The solution turned out to be much simpler than I'd anticipated (at least with Grails 1.1 anyway). I became confused after reading posts and sites some of which were pre grails 1.1. Anyway a sneak peak at the upcoming Grails in Action (can't wait for the full version!) and all is now good.

With a far degree of smugness I've decided to look at the CSS for the public facing pages. I'll admit to not having any design flair at all so its quite challenging. I've been using Adobe's Kuler to try and get an agreeable colour scheme and initial results are promising. Kuler allows you to upload an image and it picks out complimentary colours from that image. If you're design challenged its really useful.

Wednesday 8 April 2009

Grails Unit and Integration Tests

I was unexpectedly free today and decided to add some tests to the competition project. Initially I thought some nice simple domain class tests would be good. After whipping some up, I ran grails test-app and produced my test report.
However it seems that integration tests take precedence over unit tests as I get clear results even though my unit tests fail:

This would seem to be pretty poor form. I would have hoped to see failures for all tests unit and integration. If anyone has struck this problem before let me know...

Update:After reading the doc's at grails.org I've found that running the tests using grails test-app -unit solves my problem.

Wednesday 1 April 2009

Griffon

I know I haven't posted for a while but I have been plugging away at the Comp code. Mistakes have been made and new solutions uncovered. Its a great learning experience but time is always limited. I have guests about to stay soon so tonight I didn't want to get too involved in something that I can't play with again for a few days. So...

I found that MEAP has published (for free) the first chapter of a new book "Griffon in Action". Belonging to the same family as "Groovy in Action" and "Grails in Action" I'm thinking its also going to be of a high standard. The sample chapter unfortunately only goes into why use Griffon rather than the fulfilling 'dive in' approach of "Grails in Action". I understand the second chapter does this but sadly that's not a free one.

The big upside is the subject. Griffon is yet another framework but is for desktops apps instead of web apps. Totally awesome concept and something that has interested me since Uni. I've played with a few desktop applications before and honestly in Java it seems to be such a chore. Griffon cuts down on the code needed and brings convention to the party. It (Griffon) is still in its infancy (only version 0.1) but usable. Its certainly on the list of things to have a crack at...

Sunday 22 February 2009

Relationships update

After talking to a colleague apparently Grails version 1.1 does cater for many to many relationships (I've been using 1.04 for my project so far). Version 1.1 is now in Release Candidate 1 so I'll grab this and have a look.
In the meantime I think I'll continue with the new branch and work with Entrant objects. Old school I know but as they say there's no school like the old school..

Floreat Pica

Thursday 19 February 2009

Many to Many Relationships

Over the past few days I've been scratching my head over the competition project. Initially I had decided that a user would just enter their name and email and select a competition from a drop down box... easy right? Then it was suggested to me that there may be multiple open competitions at any one time. In this case ideally the user could select the competitions they want to enter using checkboxes. Still I thought this would be simple but it bought me face to face with many to many relationships.

After much grief and experimentation I was about to give in and go back to plan A when I found this article by Scott Davis. Here he explains how he had been given advice that there is no such thing as a many to many relationship instead there is usually another class that is missed when considering how the objects interact. With this sage like advice I've decided to reassess the competition design.

Now I will use another class (the Entrant) to hold name, email and a set of Entry objects. These entry objects will each map to a competition thereby avoiding the need for a many to many relationship between entries and competitions. Now an entrant can have multiple entries ( 1 to m) and each competition has multiple entries (1 to m).

Stay tuned for news on how this progesses...

Tuesday 3 February 2009

Comp update

The biggest problem I have been having with the competition code is how to handle prizes and their relationship with competitions. Do the admin users create the prizes as they create the competition? Do they create prizes in a completely separate prize and then add it to the competition? So much choice!

I guess the lesson learned here was the value of a pencil and piece of paper. I drew out roughly what I was after and whilst the answer didn't come to me straight away it was much easier to visualise. So I've decided to let the admin user create the comp and then on completion of that process add the prizes in the next step. I think this will work so now its time to think about the views. At last progress is being made...

Friday 16 January 2009

Back to the Grails Comp

I've recently been on holidays and contrary to what I had planned I have not touched any coding in the last week or so. So today it was time to get back on the coding horse. I'm planning to spend around an hour each day working on the grails comp project (without checking email, twitter or anything else).

So today was the day to take stock and see where the project is at. Firstly I had previously had a working version0.1 and decided to merge that back to Master and then to work out of master. One of the problems I have is that I seem to have quite a few branches that I've experimented with so will need to check each of them and take the good bits.

I spent some time ginning around with git and Netbeans this morning and had hoped to avoid this time wastage but am currently thinking that it will be good to use Netbeans power to assist with debugging down the track. I need to spend more time organising my versioning before diving into the next big issue.

Following this, the next thing will be to work out how to have custom prize objects instead of using strings to describe a prize. Initially this seemed quite simple however its the creation of a new competition that requires a new prize at the same time that makes things tricky. This would seem to be a fairly common problem with any web app ie creating a new object that contains a new object of another type so it will be great to get this problem solved. If you're interested download the code and/or follow along here at Github