Skip to main content
Inspiring
November 4, 2009
Question

Private variables make it hard to extend TLF classes

  • November 4, 2009
  • 1 reply
  • 1580 views

I am making a class that extends EditManager and I wanted to access pendingInsert but it is a private var, so I can not.  Is there a way around this?  Are private vars much better for memory, why not use protected? 

This topic has been closed for replies.

1 reply

Adobe Employee
November 4, 2009

There's a continuing tension between making member variables protected, and thus part of the public API, vs making them private and leaving them open to change without disruption to client code. We often err on the side of making them private, so where you see places you think we went the wrong way, please let us know what you need, and why you need it.

Are you adding more ways to insert text, and want to set pendingInsert?

- robin

November 15, 2009

It would be useful if we could get a public getter for the private _numCharsAdded variable in the PasteOperation class.  It is difficult to derive that value by other means and it seems that a public getter there would not have any implications.

The _tScrapUnderSelection private variable in PasteOperation would be another candidate.  When doing post-processing of the paste operation via FLOW_OPERATION_END, it would be useful to be able to determine any elements that were modified or removed as a result of the paste.  Currently we have to handle FLOW_OPERATION_BEGIN and create our own text scrap for the selection and keep that around for our post-paste processing.  Would be nice if we didn't have to create that second text scrap.

In general, where there is information held privately inside of operations that could be useful for those of us who pre/post process operations, it would be good to expose information that we can use to understand the changes the operations are making.  Use of tlf_internal would be acceptable for us also.  A few more examples are _origID in ApplyElementIDOperation and _origStyleName in ApplyElementStyleNameOperation.

Thanks,

Brent

November 16, 2009

Be careful what you wish for. From the experience I have had with protected

variables and functions in TLF, they do change drastically, even more than

most betas. Some of the functions I was using were not just modified but

completely disappeared when I upgraded to later builds. If adobe feels the

need to make these variables private, this is one of those times I'd defer

to them, because this framework is very new and thus very subject to

change. That's what we get when we play with the beta for a never before

released project.

- Daniel Freiman