Private variables

Discussion about JFreeChart related to stockmarket charts.

Private variables

Postby Aquajock » Tue Jan 08, 2013 9:33 pm

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.
Aquajock
 
Posts: 6
Joined: Fri Dec 07, 2012 12:03 am

Re: Private variables

Postby david.gilbert » Tue Jan 08, 2013 9:46 pm

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).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
david.gilbert
JFreeChart Project Leader
 
Posts: 11653
Joined: Fri Mar 14, 2003 10:29 am

Re: Private variables

Postby Aquajock » Tue Jan 08, 2013 10:06 pm

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.
Aquajock
 
Posts: 6
Joined: Fri Dec 07, 2012 12:03 am


Return to JFreeChart - Stockmarket

Who is online

Users browsing this forum: No registered users and 3 guests

cron