Pages

Tuesday, April 13, 2010

Data encapsulation for tools

One of the nice things about java is a the abundance of additional libraries that are available.
I'm currently working on mapping software and thankfully, there is an open source library that handles most of the work.
The first task I've been given at my new job is to allow users to upload some files that puts an overlay on the map. Fortunately I just have to provide the glue between the app and the library that does the mapping.
Except...
I don't have complete control over the tools.
The tool provides an XML parser which has a private member for the handler. It is this handler that is given the contents of the file and passes around some values to construct geometries. Under some circumstances, this handler doesn't do what I would want it to do.
In the perfect DI world, I would just hand this parser the handler that I want it to use.
Because it is private, I have to use reflection to change the value of the handler in the parser after its construction.
If the member was protected, I could just extend the parser and change the value of the handler and I wouldn't feel so dirty.

I'm interested in input though, what is the value of "private" in a tool. Should the tool creator limit what can be achieved?

No comments:

Post a Comment