[ 
https://issues.apache.org/jira/browse/OAK-1110?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13802905#comment-13802905
 ] 

Jukka Zitting commented on OAK-1110:
------------------------------------

This goes a bit against the original design idea behind the {{NodeStateDiff}} 
mechanism, i.e. that the decision on whether to recurse down a subtree is done 
*inside* a method like {{childNodeChanged()}}.

As for the {{MoveAwareNodeStateDiff}}, I think that also bends the 
{{NodeStateDiff}} design in troublesome ways. So far the diff mechanism is 
explicitly path-independent, and any path tracking is expected to happen inside 
the diff implementations instead of the by the caller. The {{move}} method 
breaks that pattern.

What would IMHO be a better solution here is an interface that's more like 
{{Validator}} or {{Editor}} (that were explicitly designed to be composable) 
where the recursion is explicitly done by the caller. Or possibly using the 
Strategy pattern inside the diff implementation to make the relevant-or-not and 
recurse-or-not decisions pluggable.


> Make NodeStateDiff composable
> -----------------------------
>
>                 Key: OAK-1110
>                 URL: https://issues.apache.org/jira/browse/OAK-1110
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core
>            Reporter: Michael Dürig
>         Attachments: OAK-1110.patch
>
>
> Currently it is not possible to warp a {{NodeStateDiff}} instance into 
> another one for delegation. The problem is that recursion is done by the 
> consumer of the {{childNodeChanged()}} call back which causes wrapped 
> {{NodeStateDiff}} "to escape". To fix that I propose to separate the concerns 
> of change notification from recursing into a subtree. For this we need an 
> extra method {{createChildDiff}} on the {{NodeStateDiff}} interface:
> {code}
>     /**
>      * Create a {@code NodeStateDiff} for diffing the passed {@code before} 
> and
>      * {@code after} states. Returning {@code null} skips comparison for the 
> sub
>      * trees rooted at the passed states.
>      *
>      * @param name  name of the child node
>      * @param before  before state of the child node
>      * @param after   after state of the child node
>      * @return  {@code NodeStateDiff} for the child node
>      */
>     @CheckForNull
>     NodeStateDiff createChildDiff(String name, NodeState before, NodeState 
> after);
> {code}



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to