Tuesday, April 28, 2009

Weird Firefox/Eclipse mouse problems

Had problems with mouse focus events in Eclipse and Firefox, only a restart would fix this. Tried different mouse. It also happened on different computers. Finally found a weird fix - click the scroll button of the mouse when it happens:

http://support.mozilla.com/tiki-view_forum_thread.php?locale=mn&forumId=1&comments_threshold=0&comments_parentId=86324&comments_offset=40&comments_per_page=20&thread_style=commentStyle_plain

Thursday, April 23, 2009

What sucks about the Geo module

GeoDataSets - ok they are useful because they store the busunitguid and other stuff. But there should be only one type of them - not different types. The different types just made it painful and added no benefit.

Also, they should have been able to be referenced by the entityTypeGuid of the domain object they were associated with, so you can easily pass in the geodataset when creating a geoobject, without having to first lookup the geodataset on something.

Wednesday, April 22, 2009

Don't have a create operation inside failed lookup


GeoTrackedEntity te = null;
try {
te = geoTrackedEntityApi.findTrackedEntity(vehicle.getGuid(), false);
} catch (UnknownFeatureException e2) {
te = addTrackedEntity(vehicle, buGuid);
}


This code is awful because it makes it hard to know when something is created. Plus you would have to have this kind of thing everywhere a find was performed.

This is truly awful. The above method addTrackedEntity then repeats this anti-pattern to add a dataset (which is required if you need to add a tracked entity).


GeoDataSet ds;
try {
ds = geoDatasetApi.findDataSetByBusUnitAndName(buGuid,
vehicle.getVehicleType().getName());

} catch (UnknownDataSetException e1) {
ds =addTrackedEntityDataSet(vehicle.getVehicleType().getName(),
vehicle.getVehicleType().getGuid(), buGuid);
}

APIs - parameter objects?

public void associateTrackedEntityWithIsUnique(GeoTrackedEntity trackedEntity,
GeoDevice geoDevice,
Date startDate,
boolean isUniqueTypedAssociated)
throws UnknownFeatureException;

The purpose of the above method is to associate the trackedEntity object with the geoDevice object. It would have been neater to specify these objects by their unique identifer, rather than requiring the whole object to be passed in. The latter causes code like this:


GeoDevice geoDevice = getGeoDevice(drvDriver.getBusUnitGuid(),deviceId);
GeoTrackedEntity te = getGeoTrackedEntity(drvDriver);
geoTrackedEntityApi.associateTrackedEntityWithIsUnique(te,gd,d,true);


We need to look up the two objects first, which is unnecessary since we already have the unique identifiers.

Another ugly code pattern is the fact that SS has created helper methods around the core api methods because they throw annoying exceptions. These exceptions should be runtime if there is nothing the coder can do about it.


private GeoTrackedEntity getGeoTrackedEntity(DrvDriver driver)
{
logger.debug("");

GeoTrackedEntity te;
try {
te = geoTrackedEntityApi.findTrackedEntity(driver.getGuid(), false);
} catch (UnknownFeatureException e2) {
te = addTrackedEntity(driver);
}

return te;
}