Page 1 of 1

Private variables

Posted: Tue Jan 08, 2013 9:33 pm
by Aquajock
I'm running into problems extending things because variables I really need to get at are declared private and have no accessor. In a similar vein, invoking protected methods from another class in a package works within your delivered jar, but keeps me from extending things outside the jar. With very few exceptions, instance variables should be declared protected, even if you can't imagine what I might do with them, because I *can* imagine. And methods accessed by anyone outside of a class hierarchy should be declared public, regardless of package issues. The various shades of meaning that are expressible in Java's visibility design are a minefield for developers working outside of your delivered jar. If I screw something up, that's my problem and I can fix it. If you lock me out, that's also my problem, but I can't fix it without breaking into and breaking up your jar. I'd rather not have to do that. Simpler is better.

Re: Private variables

Posted: Tue Jan 08, 2013 9:46 pm
by david.gilbert
I understand where you are coming from, but my aim here was/is (a) to reduce the API footprint that I have to support and (b) provide some incentive for people to come forward and describe the ways they want to extend the library. If there are fields that you think should be protected rather than private, then present an example and a patch. I *could* make everything protected, but then I'd never hear from anyone who has some good extensions.

And, in my favour, you have all the source code so you are not completely blocked. (I know, modifying the source code means you will have work to do everytime there is a new JFreeChart release, but you can't have everything).

Re: Private variables

Posted: Tue Jan 08, 2013 10:06 pm
by Aquajock
I am implementing drag-to-resize subplots in CombinedDomainXYPlot. For this, the subplotAreas instance variable contains exactly the information I need, but it is private and has no accessor. Short of breaking into the jar and recompiling it (thanks for the possibility, but I really don't like to do that), the only solution I have at this point (and I have tried several) is to duplicate most of the effort in #calculateAxisSpace(Graphics2D,Rectangle2D) in a subclass.