13 martie 2007

A fi si a nu fi...

#if defined (BOSS_A_WANTS_SOMETHING) && !defined (BOSS_B_WANTS_SOMETHING)
//piece of code
#if !defined (BOSS_A_WANTS_SOMETHING) && defined (BOSS_B_WANTS_SOMETHING)
//another piece of code
#else
#error FIGHTCLUB
#endif

Faceti economie!

if x <> 0 then x = 0

Eastern Polish Christmas Tree Notation


public
DataPair[] getHotelInformation(String hotelId, String informationId)
{
return getHotelInfo("EN", hotelId, informationId);
}

public
DataPair[] getHotelInformation(String lang, String hotelId, String informationId)
{

String key = "_HOINF_"+lng+"_"+hotelId+"_"+informationId;
DataPair[] tbl = (DataPair[])csh.getObject(key);
if(tbl!=null) return tbl;

Connection cn = null;
OracleCallableStatement cs = null;
try {
String qry = " begin HotelServices.getHotelInfo(?, ?, ?, ?, ?); end; ";
logger . debug("---"+qry+" "+hotelId+" "+informationId);
cn = DriverManager.getConnection("jdbc:weblogic:pool:oraclePool",null);
cs = (OracleCallableStatement)cn.prepareCall(qry);
cs . registerOutParameter(1,java.sql.Types.INTEGER);
cs . registerOutParameter(2,java.sql.Types.OTHER);
cs . setString(3,hotelId);
cs . setString(4,informationId);
cs . setString(5,lang);
cs . execute();
int sta = cs.getInt(1);
if(sta!=0) throw new Exception("status not zero sta="+sta);
ResultSet rs = cs.getResultSet(2);
tbl = getDataPairArray(rs);
logger . debug("sta="+sta+" key="+key+" cn="+cn);
csh . put(key,tbl);
}
catch(Exception e)
{
logger . debug("!!! "+e.toString()+" "+key);
}
finally
{
try {
if(cs!=null) cs . close();
if(cn!=null) cn . close();
}
catch(Exception x)
{
logger . debug("!!! "+x.toString()+" "+key);
logger . error("!!! "+x.toString());
}
}
return tbl;
}

W3C Standards

Pentru cei care stiu cate ceva de standardele Web, este cunoscut faptul ca Microsoft saboteaza constant standardele celor de la W3C (din care si el face parte). Surprinzator totusi, site-ul Microsoft este printre putinele care il respecta.

01 martie 2007

Fucking dayOfWeek !

if (day = 1) or (day = 8) or (day = 15) or (day = 22) or (day = 29) then
weekday = "Monday"

elseif (day = 2) or (day = 9) or (day = 16) or (day = 23) or (day = 30) then
weekday = "Tuesday"
...

Make it real, make it final !

public class IntWrapper {
private final String value;

public IntWrapper(int value) {
this.value = String.valueOf(value);
}

public String getValue() {
return value;
}
}