Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion: Propagation of Spoon model changes #1943

Closed
pvojtechovsky opened this issue Apr 2, 2018 · 8 comments
Closed

Discussion: Propagation of Spoon model changes #1943

pvojtechovsky opened this issue Apr 2, 2018 · 8 comments

Comments

@pvojtechovsky
Copy link
Collaborator

Actually the change in spoon model fires the event on FineModelChangeListener, which is registered in Spoon environment.

Problems:

  • the change evens are fired even during creation of new elements at the time when they are not connected by a parent to the model
  • we cannot improve performance of some opertations by caching data in elements, because these elements are not informed about changes of their children
  • .. ?

Idea:
May be we might propagate event about change using the CtElement#parent relation.

while(e != null) {
  if(e.getFineModelChangeListener() != null) {
     e.getFineModelChangeListener().fireEvent(...);
  }
  if(e.isParentInitialized() == false) {
    return; //or send event to Environment?
  }
  e = e.getParent();
}

WDYT?

@monperrus
Copy link
Collaborator

interesting.

what would be the fired event ? something like CHILD_CHANGE?

another point. what about moving the spoon.experimental.modelobs in spoon.modelobs? (no more experimental before too many clients use it)

@pvojtechovsky
Copy link
Collaborator Author

pvojtechovsky commented Apr 2, 2018

what would be the fired event ? something like CHILD_CHANGE?

The nicest would be to propagate all the FineModelChangeListener events through parents only (no direct call of Environment's listener) ... and as last - for backward compatibility - the Environment would receiver the event same like now.

But there are actually many events in FineModelChangeListener` so we should wrap them first into an event object and then we can send this generic event object through the chain of parents. Otherwise the event firing code would have to be copied for each event ... ugly.

another point. what about moving the spoon.experimental.modelobs in spoon.modelobs? (no more experimental before too many clients use it)

Let's wait with #1941 and remove of `experimental' until we finish this discussion and may be refactor firing of these events first ... before client's starts to use it...

@monperrus
Copy link
Collaborator

Propagating events to to the parents is a good idea, esp. if the runtime overhead is small.

But I don't see what you're waiting for for #1941.

What's the problem to settle here?

@pvojtechovsky
Copy link
Collaborator Author

what you're waiting for for #1941.

#1941 is about catching of these events ... and if we change the approach how to fire and catch events, then this PR has to be refactored again. It is no problem to refactor ... as long as there are no clients ... and there was a suggestion to move it from experimental package to normal package ...
... all that together is the reason.

@monperrus , @surli just decide the order in which you would like to do next steps.

The simplest baby steps are probably:

  1. to merge review: feat: ChangeCollector listens on changes and remembers them #1941 (ChangeCollector) into experimental package
  2. to finish review: refactor: mutable collections of Spoon model handles parent and fire change events #1917 and to refactor whole spoon model to use ModelList and ModelSet everywhere so tests in WIP: test: spoon model collections contract #1922 passes.
  3. then after everywhere is ModelList and ModelSet it will be easy to change event firing algorithm ... because it will be only on two places (ModelList and ModelSet) and no more spread over whole Spoon model.
  4. after event firing algorithm fires one generic event through one method (and not many methods of FineModelChangeListener, then we can propagate events to the parents.
  5. we can refactor ChangeCollector
  6. we can move it from experimental to standard

... quite a lot of work ... but Spoon will be nicer and more powerful again ;-)

WDYT?

@monperrus
Copy link
Collaborator

monperrus commented Apr 5, 2018 via email

@pvojtechovsky
Copy link
Collaborator Author

We just need some contributors who will implement that ... :-)

@monperrus
Copy link
Collaborator

monperrus commented Apr 5, 2018 via email

@monperrus
Copy link
Collaborator

[Issue Cleaning Marathon] No more activity here, closing the issue, and of course we can continue the discussion when something new happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants