Currently, PanelizerInterface has methods that take a ton of arguments. Adding more features to Panelizer means adding more methods with tons of arguments, or needing to add a new argument to every method. This makes it very difficult to continue to develop Panelizer, and leads to an explosion of methods and arguments.
Let's create two value objects: PanelizerDisplay and PanelizerSettings, that would encapsulate all the data that goes with a Panelizer display (so the Panels display and other metadata) and the Panelizer settings respectively, and then pass around those objects in the PanelizerInterface methods.
This would reduce the number of arguments on most methods (basically, limiting the long argument list to the methods that load those objects), making it easier to add new methods if necessary or to add new stuff to those individual objects without exploding the number of arguments across all methods.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | panelizer-n2816725-13.patch | 29.54 KB | damienmckenna |
Comments
Comment #2
dsnopekHere's a super rough first pass at the interface changes - it doesn't change any of the implementations or the things using this API, but it does sort of give the general idea.
After looking at the code, I wonder if we could put a
save()method on the PanelizerDisplay object and further simplify things by removing theset*()methods fromPanelizerInterfaceas well? If we did that, we'd probably want an interface for thePanelizerDisplayobject because it'd cease to be just a value object.Comment #3
dsnopekOr, to keep it as a value object, we could pack all the information necessary to know how to save it on
PanelizerDisplayand then have a simplePanelizerInterface->saveDisplay($display)method that doesn't need to take any additional arguments to figure out how to save it. I think I like that best because it keeps the real work in the PanelizerInterface and keeps PanelizerDisplay super simple.Comment #4
dsnopekOk, here's a patch that gets rid of the set*() methods as well per #3. The implementation and usages of the API still need to be updated (as well as lots of docblocks finished).
Comment #5
dsnopekRealized that Panelizer display and settings are two separate things. Here's a patch that adds
PanelizerSettingsand attempts to update the implementation of thePanelizerservice to work with the new value objects. I haven't actually tested this, and the code could probably be refactored further internally, but my main concern at this point is attempting to satisfy the new API.Comment #7
dsnopekThis patch is slightly easier to read (for humans).
Comment #8
eclipsegc commentedChanging the title here because I am no longer convinced of the approach the title implies.
I've toiled on this for quite a while with little to no good result. As a by-product of this, I asked phenaproxima to look over my shoulder and see if 4 eyes and 2 minds had better luck. Phenaproxima had some great ideas about moving methods onto the EntityViewDisplay which simplified a lot of things. In the mean time, we've attempted to remove many of the NULL parameters present in PanelizerInterface methods. This makes the code a bit easier to both read and grok. It likely means we could use some caching in a couple places and that we should definitely nail down render caching, but the result is code which is starting to get easier to read and follow which I think (and hope) was the spirit of this issue.
Since we're beginning to make some head way on this, I wanted to post a patch for others to see and begin giving feedback on. This won't pass tests, but I'd like to see what testbot says all the same, so NRing.
Eclipse
Comment #10
eclipsegc commentedOk, I believe this will pass tests, continuing to refactor from this.
Eclipse
Comment #11
damienmckennaAsking for dsnopek to take a look.
Comment #12
damienmckenna@EclipseGc: Are you finished with your refactoring?
Comment #13
damienmckennaA minor reroll.
Comment #14
damienmckennaI believe "needs work" sums up EclipseGc's comment in #10.
Comment #15
damienmckennaBumping the issue to see if dsnopek can give this a review.
Comment #16
damienmckennaFrom this week's scotch meeting:
We (japerry and I) agreed to let EclipseGc continue on the path he was currently taking.
Assigning this issue to EclipseGc.
Comment #17
andypostwhy not PEVD:class?
would be great to document them
Comment #18
damienmckenna@andypost: I think the goal is to polish it off once the decision was made what direction to take.
Comment #19
damienmckennaAdditional follow-up from dsnopek:
Both EclipseGc and tim.plunkett have a plan to work around this correctly, quoting tim.plunkett:
Comment #20
damienmckennaThis won't go in 3.x.
Comment #21
damienmckennaMarking this Postponed until 3.0 is out.