Embracing the Messiness in Search of Epic Solutions

Category: Programming Language

  • Hibernate + Joda Time: Auto Registering Type

    OVERVIEW Jadira Usertype is required when using Joda Time with Hibernate 4. The Joda Time objects are annotated accordingly in the Hibernate entity, and they looks something like this:- PROBLEM This solution works, but it is rather tedious because I can never remember the actual @Type to write, thus I always end up copying and Read More…

  • Backbone: model.destroy() Always Call “error” Callback Function

    PROBLEM Let’s assume we invoke person.destroy() to delete a person:- … and let’s assume when person.destroy() is invoked, it will call /person/{personId} DELETE. Here’s how the Spring MVC controller API might look like:- When we execute person.destroy(), the error callback function will always get called even though the HTTP status is a 200 OK. Why? Read More…

  • Groovy: java.lang.StackOverflowError When Implementing equals()

    PROBLEM While migrating a portion of my Java code to Groovy code, I got bitten by the Groovy operator loading feature that I should have known better… and my pride hurts, but hey, I admit I write shitty code. Consider this simple POGO with custom equals() and hashCode(), both implemented using Google Guava libraries:- What Read More…

  • Deleting Cached Web Page by URI in CodeIgniter

    PROBLEM CodeIgniter contains a wonderful feature that allows me to cache web pages to speed up the page loading. The problem is there’s no easy mechanism for me to delete specific cached web pages, especially after I have updated the page contents. I have sucky two choices:- I always do the latter even though I Read More…

  • Suppressing FindBugs Warnings

    PROBLEM FindBugs is one of the many great static code analysis tools that I use everyday. However, the generated report may usually contain a few false positives that forces me to weave through them whenever I rerun my build on Jenkins. For example, I’m using Google Guava to construct my equals(…) and hashCode():- FindBugs will Read More…

  • How to Unit Test Spring MVC Controller

    SCENARIO Let’s assume we have the following controller that needs to be tested:- SOLUTION 1: “Works but It Won’t Get You the Promotion” This working solution relies on:- While this solution works, but it has a few problems. This test case strictly tests the actual controller API, but it completely disregards the URI and request Read More…