Kyle Banks

Hello, World!

Written by @kylewbanks on Feb 18, 2013.

Welcome to my new site. If you ever took the time to look at the old site, first of all thank you, secondly you will know it was severely lacking. The design was mediocre at best, and it was all very static. I wanted to start getting into blogging again, and not just use this space to showcase some of my work.

The old site was written in PHP and had no administrative interface. Any time I wanted to add, edit or delete content, I had to go straight through the database to do so. Obviously this is less than ideal. The code was also a mess, so updating the site itself was always a monolithic undertaking.

I've built the new site with Grails, which is a Java/Groovy web framework based on Django and Ruby on Rails. If you haven't tried Grails, I highly recommend you do so. It is incredibly powerful, and offers all the robust and scalable libraries of Java, without the ridiculously verbose syntax that Java tends to impose. Take a look at this sample code containing the model I use for the tags on this site:

package com.kylewbanks.blog

class Tag {

    String displayName
    String url

    static constraints = {
        displayName(nullable: false, blank: false, unique: true)
        url(nullable: false, blank: false, unique: true)
    }

    static mapping = {
        sort displayName: 'asc'
    }

    public String toString() {
        displayName
    }
}

This model actually does way more than it appears. It offers all of the CRUD operations required when using a database (insert, update, delete). It offers a massive range of dynamically injected SELECTs such as Tag.findByTitleAndURL(title, url) by adding methods for every combination of properties on your model. The constraints mapping declares how the data will be persisted in the database and the validation it will have to pass in order to be saved successfully. It even allows you to define the default sort order when retrieving models using the dynamic queries. The best part is that Groovy compiles into Java code, so any old Java libraries you have are 100% compatible with Grails!

Obviously Grails is powerful, but the reason I am telling you all of this is that I will most likely end up open-sourcing the entire blog once I have finished polishing the admin panel, and am confident that the code is stable.

In any case, stay tuned for more posts ranging from code snippets to general thoughts on the tech world as a whole. I have brought over a few posts from my old blog, and look forward to writing more soon!

Let me know if this post was helpful on Twitter @kylewbanks or down below, and follow me to keep up with future posts!