52North / IlwisCore

Integrated Land and Water Information System (ILWIS) is a remote sensing and GIS software. ILWIS Core is the functional center of ilwis4..
http://52north.org/communities/ilwis/
34 stars 13 forks source link

ConnectorFactory creates connectors unneccessarily #68

Closed ridoo closed 10 years ago

ridoo commented 10 years ago

Currently the ConnectorFactory::explorersForResource() creates a connector explorer for each Resource available to check if it can be used. Performance at this part will be very important especially when more and more resources become available during startup (imagine a stored Ilwis session reloading lots of resources from disk/database/remote services).

Besides the fact this brute force method is highly imperformant it also enforces developers to keep their constructors clean. When something is implemented in the constructor it will be executed every time a resource is being checked even if it can't be used by the connector. This could be communicated in a best practice, though, but I still think that this is bad practice as this behaviour is more or less hidden to the developer.

MartinSchouwenburg commented 10 years ago

this is a design choice. The connectors are not created unneccisarily. The virtual mechanism of a connector is used to query its capabilities. As long as the constructor is leightweight ( as they are now) this is not a problem. There are other solutions possible but they all lead to more code and questionable conceptual value.