To a beginner writing unit tests may seem to be an overhead and a low productive affair. But this could be due to the way he chooses to write tests. One can quite easily be productive at writing unit test cases as well. Following are a few things that I follow to write the spock unit tests cases in the grails application. I hope these...
We recently upgraded to Grails 2.3 and found some pleasant features in the rewritten Data Binding. This raised my interest to look further into what is new and found some interesting things that could be useful: We can create a global setting for the dataBinding of the dates using the following setting in...
After attending the recent Groovy Grails conference in London recently, I realized how much one can learn from a conference. One gets exposed to some fresh ideas and trends that can really be enriching as a professional. Meeting like minded people and sharing the ideas during the course of the conference is just an added advantage. At the...
The day two at GGX '13, London continued to be spell binding and fun filled. The sessions, again, were really nice and proved to be valueable and insightful. Here are some of the highlights: Road To Grails 3.0 - By Graeme Rocher The session started with overview of the new features of Grails 2.3 and then moved to Grails 3.0. The...
Have you ever wondered how to overload "plus" operator in Groovy ? It is as easy as adding toppings to your favourite pizza. Let me explain. Let us taka a class for Pizza: [java] @ToString class Pizza { String name List<Topping> toppings double price } [/java] And another for the Topping: [java] ...
Following DRY is practised religously in my current project. Recently, I identified a case where code repetition had long been ignored. We used to pass either a domain object or a command object in the view model. Due to this, many domain methods had to be duplicated in the command object. This was probablematic because one would easily...
A few days ago I faced a problem of evaluating dynamic expressions on domain objects. The scenario was that, depending upon the user input, I needed to sort a list of objects on some properties, which were nested deep in the object, e.g., [java] student.course?.college?.name // if a user chose to sort students by college name ...
Following DRY is at the heart of grails. While saving domain objects in our project, we used to copy the domain class constraints to the Command Objects (pretty ugly as it is), until we found that we can import constraints directly from the domain classses using importFrom() method in Grails 2.0 [java] class VenueCO { String name ...
Recently, I had a usecase to share same http session between different subdomains. The idea was that if a user is logged in on "somedomain.com", he need not to login again to go to subdomain.somedomain.com. The same http session should be usable. I started off on the wrong foot by looking into the SpringSecurity plugin, which I had been...
Most of us have experienced how important the Unit test cases are for our code base. I feel the other thing that is equally important, is the speed at which we can write the unit test cases. In Unit Testing, initializing different objects in setup of the test case (e.g., while testing a method which queries the database) can become a...
In my current project, we were required to implement Instance Based Security. The idea was to find a clean solution separate from the main business logic of the application. We took a clue from the Spring Security Plugin to use the Annotations to do our job. All we wanted to do was to develop annotations for actions, which could help to...
I have been working on grails for quite some time now. As a beginner, I had doubts about where to place the business logic in grails. Seeing the CRUD, one can easily be misled into putting most of the code in the actions, but as the code base goes bigger, it becomes difficult to manage those actions. Coming from the java background, with...