Monthly Archives: August 2012
Never use data which can be localized as part of business logic
I was reviewing a code and came across something as
public doSomeStuff(String shortMonthName){ if(shortMonthName.equlaIgnoreCase("jan")){ //do something} }
.
In this code client passes a month name based on which some logic is executed.
At first it might look as whats wrong? hmm ..what if in future multilingual support is introduced -the month names will be localized and the client supplies equivalant of “jan” in a language other than english –it will simply fail.This is a very simplistic use case, but hope I make my point
Never use data which can be localized as part of a business logic
Path parameter to FileInputStream
A basic discovery about FileInputStream 🙂
FileInput stream always takes a absolute path
new FileInputStream("must be an absolute path")
.. if a relative path is given and even if that relative path is added in the class path then also it will not work.