Thursday, February 19, 2015

Database Migrations for Java Application

One of the tools that I've used in the recent days that merits a blogpost is Flyway.
Flyway is a database migration tool that provides database state migration in applications that do not have a built in migration.
Rails and (some) rails based frameworks already have this, but it is pain to implement this in say, a java application. Flyway alieviates the need to create this as it has native support for many popular databases(including cloud based Dbs and counting?) as well as a Java based api with support for build tools like ant, maven and gradle.
It has only 6 basic functions: Migrate, Clean, Info, Validate, Baseline and Repair.
Unlike rails, you are not restricted with timestamp values (and they are a pain if you have renamed a file and left out a digit - which makes ordering difficult to trace). Here, you can specify a file as V__.sql

While a rails developer is bound to miss the up and down in a migration file (as the rails like backward migration is missing in the current version), the rest of the application works as desired and is indeed handy.

Having some significant traction, this project is in use by different teams and does not require huge overhead/configuration to work easily with hibernate/spring based applications as well. The project is located at github so you can easily head over there to check out its source as well.

Tuesday, January 27, 2015

Book Review: Mockito Essentials

Book Review: Mockito Essentials by Sujoy Acharya

Mockito essentials is a straightforward insight towards writing proper form of unit tests using mockito framework. Targeted at existing developers, this book goes beyond the documented library and explains the method of correctly writing unit tests and its corresponding code.
The book starts by introducing test doubles, or assumptions that we make while writing unit tests which is essentially done through mockito, effectively laying the foundation of the book. Two subsequent chapters are devoted to the innards of the framework - which is very handy if you have mockito's programming reference ready.
However, the main problem of unit test lies in its implementation as real world code is generally not testable and often is unchangeable. Using mockito under BDD tests is also worth mentioning as this concept is not covered elsewhere till now. The book concludes with implementation of mockito based tests over webservices and rich client applications.
Overall, the book not only covers the mockito framework but also covers practical advice regarding testing existing code and making both legacy and new code testable and I'd highly recommend this book if you are looking to write unit tests in java applications.

Disclaimer: I received a copy of this book from packt publication before doing a review.
Access the book here:

Sunday, January 11, 2015

On finding loopholes through visualization

Sometimes, visualization provides you with insight that is not instantly available. for example, I was playing with the open data that Indian Government provides for irrigation methods in different districts of India, and here's the aggregate data:
 The visualization above lists all the power sources used for irrigation across India. In most of the states, this was coming similar to what was expected (such as larger use of solar pumps and windmills in Gujarat and Rajasthan), but there were few anomalies too, like in the display below:
This information is obviously incorrect as someone has erroneously or lazily set all the non manual sources for irrigation to the Other/uncategorized source and thus, this set of data becomes inconsistent with the rest of the data.

Being on the information highway (with Right To Information) is important for India, but still there is still to go before we are able to make this data comprehensive enough for forecasting and predicting useful outcomes.

Wednesday, January 7, 2015

Hack learning android, freelance and other ramblings

In between doing mundane things in life, I've started doing more work to keep myself sharp as my office work has diminished vastly. This year has turned out good for me as I've started freelancing on my own on part-time basis and am currently relearning android application development to take advantages of the newer generation phones and create an app or two. The new android studio merits a mention here - from eclipse, it has now moved to intellij ide and different wizards as well as gradle based build tool is added, which augments development. However, emulating newer mobile devices does not work on my machine as it takes up quite a lot of time to initialize and random crashes also occur, so using a physical devise is the only workable option for now. My approach towards learning has also undergone a change and now I am working in shorter sprints of hack and learn cycles that ease my understanding process.

I get sidetracked by various side projects often and am also preparing for the hybris core and commerce developer certification, which to me seems like a college level exam - you sulk at it till the penultimate day. I do hope that businesses realize the importance of knowledge over a certificate given the presence of questions to be asked in exam over the internet, often called dumps.
Since I am having the luxury of time at my disposal, I am able to plan for my tech startup/business idea that would sustain me in future as well as allow me to be an entrepreneur.

Tuesday, December 30, 2014

Book Review: Learning Python Testing by Daniel Arbuckle

This is a review of Learning Python Testing by Daniel Arbuckle which as its name suggests, delves into testing with python. The testing frameworks covered are already covered in comprehensive python texts but instead of only high level overview, this textbook covers various testing frameworks and approaches in detailed manner.
The first chapter covers various forms of testing - something which could be covered in few subtopics and test driven development could have been discussed in greater detail. It then moves into doctest, which is unique approach in python and was discussed in depth - I've only known it vaguely before and the provided details opened up a sea of possibilities for me. For instance, the AVL tree example provided an excellent demonstration of doctest and is worth quoting. The next chapter provided unit tests with doctest and correctly explained the essence of unit testing. The PID controller example however was confusing and it took me frequently eyeballing the code - the logic used was complicated and consequently the test cases were larger. Next, mock objects were detailed - which are not present in other python texts. unittest.mock library in python3 was explained in depth before covering the details of this module. In the next chapter, the Nose test runner was discussed and its various customizations were also explained.
Test Driven Development was introduced relatively late in the book after all the testing frameworks were covered and covered writing specification and tests before code. For someone new to TDD philosophy, this book offers excellent introduction and covers all its facets and challenging the reader to do more - which I found as a pleasant surprise. This was followed by integration and system testing doctrine. The final chapter covering importance of testing in code coverage, version control and continuous integration wrapped up this handy textbook sufficiently.

Apart from some places where I found the text opinionated with the example taken, I enjoyed the rest of the book and specially places where the reader is asked to get off reading and try things to test his/her knowledge of the topic.

Disclaimer: I received a copy of this book[] for doing its review.