I often do stuff like this while coding:
getNamedJdbcTemplate().update(sql, new MapSqlParameterSource() {
{
addValue("a", obj.getA());
addValue("b", obj.getB());
addValue("c", obj.getC());
}
});
or this
getJdbcOperations().queryForObject(sql, new Object[] { id}, new RowMapper<Obj>(){
@Override
public Obj mapRow(ResultSet rs, int rowNum) throws SQLException {
// TODO Auto-generated method stub
return null;
}});
I also use a lot off Inner classes with Java methods.
For sure, if I use the code more then once I will place it on a different class so I can reuse it... the problem is that my team mates don't like this, and nobody is able to give me a proper reason of why not...
They talk a lot about memory leaks and Garbage Collection(GC) but I believe that those are stuff from the past. I'm using Java6 and Spring 3. the apps are deployed on a Tomcat 6 server.