Groovy
Getting Groovy with Fibonacci
Fibonacci is probably the best example to wrap your head around memoization.
Nick Verlinde shows, in this marvellous blog post, how to apply memoization in Groovy to improve the performance of a hard calculation like fibonacci. The post is, as well, a cautionary tale about recursion.
Use Categories to add functionality to classes
If you have worked with dates in Groovy with the aid of use(TimeCategory), you have already use Categories. Checkout the linked post by explainer in chief, @mrhaki to learn more.
Sergio, do you ever use Categories? Yes, I do. Categories are present in many programming languages. I use them heavily in Objective-C. For example, to add a md5() function to the String class. Another example from this week's work. I needed to calculate the standard deviation of a collection in Groovy and a category created by @ohndy did the job.
Grails
Using External Configuration Files Per Environment
You should not have your production settings, specially database password in source version control.
mrhaki shows how to use different configuration files per environment. He goes deep explaining were we can place configuration files and the override order. Must read for Grails 3 users.
Just remember to your application-production.yml to .gitignore. 😝
Migrate from resources plugin to asset-pipeline
@ilopmar recently joined OCI, a source of pride for the Spanish Grails community. In this post he explains how to transition from the resources plugin to the asset-pipeline plugin. If you are planning to move an old Grails 2 app to Grails 3, this tutorial will certainly aid you.
Do you want to go deeper about the Asset-Pipeline plugin? I linked to a great Video in Issue 19
Libraries
Learning Spring Boot
Grails 3 sits on the shoulders of Spring Boot. There are many configuration options which are possible thanks to Spring Boot. We saw it in the latest issue with the @Value annotation for injecting config values.
From the Grails technologies, Spring has been always my weakest point. If you are looking for Spring Boot Courses, @therealdanvega has two courses. A free introductory course and more complete paid Spring Boot Intro.
Note: the free course includes a coupon code to make the paid course just 19$
Comment
Last week Groovy Calamari reached 5️⃣0️⃣0️⃣ + subscribers. Thanks to everyone who subscribed and thanks again if you refer this newsletter to your coworkers or Groovy accomplices.
This issue highlights two cool Groovy features; Memoization and Categories. Enjoy!
Sergio del Amo