Groovy as your primary language

Groovy is fantastic. Remind we why I still program in Java?

I’ve been watching some Groovy videos from the recent SpringOne2GX conference. I’ve always really liked Groovy, and use it for all my personal projects. It’s so much more succinct, and the tools around it are very powerful.

After watching these videos, and seeing even more power available, as well as the fantastic enhancements around Type Checking and static compiling, I’m left asking myself why I code in Java at all.

Almost all valid Java code is valid Groovy code, so it’s easy to transition at your own pace. Groovy then allows you to remove so much ceremony, plus has so many powerful additions. AST transforms for creating an Immutable object. Defining a POJO while only having to define the properties. Powerful DSL’s that if written correctly, are Type checked at compile time, rather than at runtime.

Spock testing framework combines all the power of Junit, Mockito and JUnitParams in an even easier to read and use DSL for testing.

Even if you use Spring Boot, there is very good support for using Groovy everywhere. The main language, as the templating language (the new Groovy MarkupTemplate DSL is fantastic. Type checked at compile time rather than runtime, and optimizations performed by the compiler to improve performance at runtime).

Replacing Spring Data with GORM (from Grails). Spring Data allows for reflection based methods, BUT these aren’t checked until run time, and are limited in their functionality.

Using the latest GORM DSL, the queries are checked at compile time, and are much more flexible and readable. Instead of relying on a very long method name, a closure is used to define the request.

people.find {
name == ‘George’
isAdult()
}

This will ensure the People object has a name property and an adult property at compile time.

DSL’s written correctly, are type checked at compile time, and your IDE can provide code assistance. Very powerful tool.

Watch the videos below and learn more about Groovy. I intend to incorporate it into my next project, and don’t want to code Java again.

Groovy after all these years at Mutual Life: http://www.infoq.com/presentations/groovy-legacy
Advanced Groovy Features: http://www.infoq.com/presentations/groovy-features
Modern approach to writing DSL: http://www.infoq.com/presentations/groovy-dsl-2015

Site security: Use pass phrases and not complex passwords

An excellent article on how to enforce pass phrases and why they outperform traditional ‘secure’ passwords with complex rules.

It’s also much easier, and less frustrating for your users.

http://uxmovement.com/forms/why-passphrases-are-more-user-friendly-than-passwords/

I recently had to change my Atlassian password. The password input placeholder read ‘A few words you’ll find easy to remember’. Nice to see they’re following this advice.

Intellij IDEA memory settings

From http://tomaszdziurko.pl/2015/11/1-and-the-only-one-to-customize-intellij-idea-memory-settings/

Give more memory to IDEA and it will perform better. No big surprise, but some recommendations based on 3 different approaches. I now use the ‘Balanced’, summarized below. More memory without starving everything else on the machine.

2GB for Xmx and 2GB for Xms, more balanced approach to the memory consumption

-Xms2g
-Xmx2g
-XX:ReservedCodeCacheSize=1024m
-XX:+UseCompressedOops

For Mac, it’s in ~/Library/Preferences/IntellijIdea15/idea.vmoptions.
For Windows, it’s in Program Files (x86)/JetBrains/bin/idea.exe.vmoptions.

Update: Intellij provides a shortcut from the Help menu to customize the VM Options. It will open or create the file in the OS specific location. On the Help menu, choose ‘Edit Custom VM Settings’.

Starting from scratch isn’t always the best approach

Something to keep in mind. Green field isn’t always the best answer.

Here’s an example where they took a 10 year old existing application and applied UX. The end user was very satisfied with the outcome, and didn’t care about anything under the covers.

The author came to the realization that doing it this way made the most sense, as it would have taken much longer to start from scratch, and in the user’s eyes would only be marginally better.

Too often we want to re-write a system from scratch rather than update an existing one. Something to be very wary of.

https://dzone.com/articles/getting-into-the-development-time-machine