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 

About these ads

About ChandanPandey

Try to come up with a good design as by product of good coding practices

Posted on August 31, 2012, in Coding practice, Java and tagged , , . Bookmark the permalink. 1 Comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 32 other followers

%d bloggers like this: