Fake
Fake objects are working implementations; mostly, the fake class extends the original class, but it usually hacks the performance, which makes it unsuitable for production. The following example demonstrates the fake object:
public class AddressDao extends SimpleJdbcDaoSupport{
public void batchInsertOrUpdate(List<AddressDTO> addressList, User user){
List<AddressDTO> insertList = buildListWhereLastChangeTimeMissing(addressList);
List<AddressDTO> updateList = buildListWhereLastChangeTimeValued(addressList);
int rowCount = 0;
if (!insertList.isEmpty()) {
rowCount = getSimpleJdbcTemplate().batchUpdate(INSERT_SQL,…);
}
if (!updateList.isEmpty()){
rowCount += getSimpleJdbcTemplate().batchUpdate(UPDATE_SQL,…);
}
if (addressList.size() != rowCount){
raiseErrorForDataInconsistency(…);
}
}
AddressDAO extends from a Spring framework class and provides an API for mass update. The same method is...