Posts

Showing posts from April, 2009

Static Import In Java 5

Constant Interface Anti pattern is a real hot topic of discussion in java, after browsing the web for hours I am not sure whether to use it or avoid it. Constant Interface is a interface which defines some public static final constants. And when we need those constants we can implement the Interface and uses the defined constants or we can access the static constants as InterFaceName.ConstantName. The book Effective Java by Joshua Bloch discusses this problem he calls it "Constant Interface Anti pattern." Poor use of interfaces and  Exposes Implementation Detail are some of the issues why author advocates to avoid it. public interface Constants {       public static final double PI = 3.14159;       public static final double PLANCK_CONSTANT = 6.62606896e-34;   }     public class Calculations implements Constants {       public double getReducedPlanckConstant() {         return PLANCK_CONSTANT / (2 * PI);     }   } Java 5 comes with a Static Import concept. We can solve the

Liquibase Incremental Database Changes

LiquiBase is used for managing, tracking and applying database changes. It uses XML file for storing incremental changes to data base.These xml file stores both Database structures(DDL) and codes.LiquiBase is an open source (LGPL) Library The following are some of the features which attract LiquiBase a lot 1) It is Open Source 2) It is Database independent 3) Supports rolling back changes 4) Supports merging of changes from multiple developers The XML file which contains input to Liquibase is called databaseChangeLog File. The following is a example of a empty databaseChangeLog file <databaseChangeLog         xmlns=" http://www.liquibase.org/xml/ns/dbchangelog/1.8 "         xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "         xsi:schemaLocation=" http://www.liquibase.org/xml/ns/dbchangelog/1.8         http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.8.xsd "> </databaseChangeLog> The following fragment is a changeset, the