Lessons Learned Teaching a Groovy/Grails Course

Jacob Aae Mikkelsen

Agenda

  • Course description

  • The Students

  • Example questions

  • Results

  • Reflections

Jacob Aae Mikkelsen

  • Senior Engineer at Lego

    • Microservice based architechture on JVM

  • Previously 4 years at Gennemt├Žnkt IT

    • Consultant on Groovy and Grails

  • External Associate Professor - University of Southern Denmark

  • Twitter @JacobAae

  • Blogs The Grails Diary

DM844 - Web development with Groovy and Grails

logo

The Practical Info

  • University level (3rd & 4th year)

  • Full-stack Course

  • 42 Students

  • 2 * 2 hours teaching each week

Goal

To bridge the gap between the theoretical academic world and the outside practical world
  • Practical project

  • 4 parts

  • 14 groups of 3 student

  • Same proposal → 14 very different results

Technologies

technologies

Evaluation

  • Group project

  • Written report

  • Oral exam

Formal evaluation goals (1)

  • Design an application in an MVC web framework, including the separation of logic and presentation

  • Apply and demonstrate the use of tools for static code analysis

  • Apply and demonstrate the use of tools for test coverage

  • Evaluate and comment on code quality, for example. by code review

  • Use version control and semantic versioning with a group of other developers

Formal evaluation goals (2)

  • Analyze and test the security in web applications

  • Configure a cloud based hosting server for a webapplikation with database access

  • Use continous integration and automate the proces of testing and deploying

  • Implement the designed webapplication, with support for multiple languages, responsive design and asynchronous updates (one-page-app)

The Students

Characteristics

  • 75% Computer Science

  • 25% Software Engineering

Characteristics

  • Great with algorithms, complexity etc

  • Not used to focus on code quality and testing

  • Not used to configuring servers

  • Never used CI

Snippets

String toString() {
    return this.firstName+" "+this.lastName
}

Snippets

class SalaryServiceSpec extends Specification {

    def setup() {
    }

    def cleanup() {
    }

    void "test something"() {
    }
}

Snippets

def createNewProject(params) {
    def projectOwner = ProjectOwner.get(params.projectOwnerID)
    def project = new Project(title:params.projectTitle,
        shortDescription: params.projectShortDesc,
        description: params.projectDesc, projectOwner:projectOwner
    )
    project.save(failOnError: true)
    projectOwner.addToProjects(project)
}

Snippets

def findProjectRequest() {
    ProductRequest theProject = ProductRequest.findById(theId)

    return theProject
}

Snippets

} else if(areaIn.bookings.getClass() == org.codehaus.groovy.runtime.NullObject){

Snippets

@Build(Area)
class AreaUnitSpec extends Specification{
    void "Show build method"(){
        setup:
        Area.build(name: 'Pitch One')

        when:
        Area area = Area.findByName('Pitch One')

        then:
        area
        area.name == 'Pitch One'
    }

}

Example Questions

Lets look at a few of the questions I received during the course

Performance Issue

Browser hangs on create on some of the classes when using scaffolded views

Performance Issue

class Patient {
    Integer patId
    String name
    String phone
    String email

    static constraints = {
      name size: 2..255
      email email: true
      patId range: 1..100000, unique: true
      phone size: 8..12, matches: "[0-9]+"
    }
}

Using dateCreated

We would like to use dateCreated in validation, as some of the dates cannot be set in the past (at creation time)
Not set before it is saved - cannot use new Date() on edit

Data modelling with embedded classes

For a delivery company, we have a delivery having two embedded delivery points each having an embedded address. Gorm cannot handle this (naming clash)

Geb testing

The Geb test fails because the bottom bar is on top of the button
when: "we click next"
JavascriptExecutor executor = (JavascriptExecutor) driver
executor.executeScript("window.scrollBy(0,500)")
$("input", name: "Next").click()

Results

Project Outcome

Some of the results

Reflections

Feedback

  • Learned new stuff

  • Lots of waiting while compiling and running tests

  • Real work-life experience

Up’s

  • Dynamic scaffolding - and speed to get started

  • Great Project results

  • Engaging students (most of them)

  • Helpfull in Facebook Group

  • Wow-factors

    • GORM

    • AST transformations

    • Spock - where clause for testing

Down’s

  • Huge workload

  • Hard to compare different projects

Recommendations

Next iteration
  • Point to Github student pack

  • Use Grails 3

  • Fixating the project description

Thanks

Jetbrains for IntelliJ educational license for all students Digital Ocean For vouchers for servers

References

Questions?