[MAGNOLIA-5935] Extra Ops for NodeBuilder Created: 29/Sep/14 Updated: 08/Oct/14 Resolved: 02/Oct/14 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 5.3.4 |
| Type: | Improvement | Priority: | Neutral |
| Reporter: | Jan Haderka | Assignee: | Jan Haderka |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | quickwin | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Template: |
|
||||||||
| Patch included: |
Yes
|
||||||||
| Acceptance criteria: |
Empty
|
||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||
| Date of First Response: | |||||||||
| Description |
|
When using NodeBuilder to create more complex structures some extra ops come handy
|
| Comments |
| Comment by Magnolia International [ 29/Sep/14 ] |
|
conditional and ifTrue are redundant, and both break the indentation. conditional without the false Op might be the only that doesn't break it. All first 3 imo create opportunity to have more fragile code; we made the same mistake with tasks, and I'd like to avoid repeating that. onChildNodes existed in info.magnolia.nodebuilder.Ops, no idea why it's been removed. It's always been the intention (again, just like with Tasks) that one provides their own Ops. So perhaps instead of generic "getOrAdd", "ifs" and "conditionals" that end cluttering the readability one's node builder code, you can come with local, more specific ops ("addOptionalFolderSupport"). It's not forbidden to generate ops instances and add those to collections, etc. (e.g. don't try to shoe-horn everything into ops, but build collections of ops with regular code) |
| Comment by Jan Haderka [ 29/Sep/14 ] |
Yes they are redundant. In the linked issue -
True again, but again that doesn't help readability of the code. In so many cases you don't know if certain path exists or not and all you need is to add something to that path. I found it much easier to read longer operation chain with getOrAdd rather then having explicitly code checks for existence outside and then inserting different ops based on those external checks. The power of the API is in fact that you can write and read code just like long sentence of semi-broken-english w/o having to jump away to check some conditions. |