We prefer to keep member variables private unless there is a compelling reason 
not to. In this case, a protected getter would meet the use case and wouldn't 
expose the base class to corruption by poorly implemented subclasses.

On Jun 13, 2010, at 7:14 PM, aappddeevv wrote:

> Yes. But then the element directly is exposed to the subclass. Your approach
> is the right thing to do in the long run though. If you are subclassing the
> serializer you are probably not worried about protecting clients anyway :-)
> 
> You could also just make the element protected instead of private which
> involves a one-word change.
> 
> 
> 
> -----Original Message-----
> From: Greg Brown (JIRA) [mailto:[email protected]] 
> Sent: Sunday, June 13, 2010 7:00 PM
> To: [email protected]
> Subject: [jira] Commented: (PIVOT-527) add getEnclosingObject() to the
> serializer to support PIVOT-514
> 
> 
>    [
> https://issues.apache.org/jira/browse/PIVOT-527?page=com.atlassian.jira.plug
> in.system.issuetabpanels:comment-tabpanel&focusedCommentId=12878445#action_1
> 2878445 ] 
> 
> Greg Brown commented on PIVOT-527:
> ----------------------------------
> 
> Might it not be more intuitive (and just as, if not more, useful) to simply
> add a getCurrentElement() method to WTKXSerializer?
> 
> 
>> add getEnclosingObject() to the serializer to support PIVOT-514
>> ---------------------------------------------------------------
>> 
>>                Key: PIVOT-527
>>                URL: https://issues.apache.org/jira/browse/PIVOT-527
>>            Project: Pivot
>>         Issue Type: Improvement
>>         Components: wtk
>>           Reporter: Appddevvv
>>           Priority: Minor
>>            Fix For: 1.5.1
>> 
>> 
>> When using new capability in PIVOT-514, sometimes you need to get the
> enclosing object. While this could be added to the createInstance method,
> you can also add it as a protected method. The code is below:
>> /**
>>     * Return the enclosing object which is this element's parent's value.
>>     * @return
>>     */
>>    protected Object getEnclosingObject() {
>>      return element.parent==null?null:element.parent.value;
>>    }
>> This allows extensions of the serializer to know what the enclosing object
> is. From there, the tree can be climbed back to the root.
>> It is possible to make instance creation a strategy design pattern, but
> the subclassing approach is sufficient for now but there are not strong
> use-cases supporting it.
> 
> -- 
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
> 

Reply via email to