Groovy file operations - execute around pattern in action In an older post, I described Execute Around Pattern. In this post, let's understand how this pattern simplifies the solution while reading from files and writing to files. Suppose we have a text file that contains a few names one name per line. We want our program to
IDE generated code - a good idea? In my previous post I mentioned how pain acted as a trigger to positive action. In this post, let's analyse potential solutions to the problem I had mentioned in the above post and what can we learn from them. At the time of this incident, our team was
Effective Java with Groovy - How Language can Influence Good Practices Effective Java with Groovy - How Language can Influence Good Practices from Naresha K
Micronaut Service with Groovy & Spock Micronaut supports Java, Groovy and Kotlin languages. In this post let's explore creating a service using Groovy language and Spock testing framework. If you don't have the Micronaut CLI installed, this post has the details of how to get it installed. 1.1.0 is the
Groovy Power Assert When I googled for 'power assert', the first result found was the JavaScript library power assert. The second link contains an interview with the author of this library. He acknowledges the inspirations from Groovy ecosystem. Borrowing good ideas from another language/ ecosystem has had positive influence on many
Micronaut Configuration for CLI In my previous post we saw how to create a service using micronaut CLI. When you create an application/project using the CLI command mn, the preferences you entered are saved in a file named 'micronaut-cli.yml', which can be found at the project top level directory. Let&
Groovy Execute Around Pattern In my previous post, we saw how languages with higher order functions make the implementation of Command Pattern very trivial. With a slight modification, we can achieve the Execute Around pattern. Suppose we have two types of transactions (atomic operations). Let's represent them using closures transactionOne and transactionTwo
Command Pattern in Groovy using Closures Command Pattern is one of the design patterns published in the GoF book. Command pattern is essentially encapsulating various types of request under a unified interface. The goal here is to minimise the coupling between executor and the client, with the system retaining the ability to evolve with new commands.
Groovy - Strategy Pattern using Closures Suppose we have a list of numbers. def numbers = [1, 2, 3, 4, 5, 6, -1] We are asked to do the following 1. Find out all the even numbers in the list 2. Find out all the numbers divisible by 3 3. Find out all the negative numbers in