RFC - cleanup Fusion prototype-names

Fusion contains some unlucky names for prototypes that made sense at the time but
nowadays are a hurdle for new developers. An commob example is the Array prototype that returns a concatenated string, if you really mean array you have to use the RawArray prototype.

Since we cannot simply alter those names i suggest to define better names alongside the old ones for Neos 4.2.

Suggested renamings:

  • Neos.Fusion:RawArray -> Neos.Fusion:Object
  • Neos.Fusion:Array -> Neos.Fusion:Concatenation (maybe Neos.Fusion:Concat)
  • Neos.Fusion:RawCollection -> Neos.Fusion:Mapping (also use items-attribute instead of collection)
  • Neos.Fusion:Collection -> Neos.Fusion:Iteration (also use items-attribute instead of collection, maybe support content in addition to itemRenderer for afx)

The old names should be deprecated but i suggest to still support them for a while. In the future we can extract them into a separate package but i suggest to wait at least until Neos 6.

In addition i suggest to seperate the MenuItem Generation from the current template based rendering.

This would add the following prototypes:

  • Neos.Neos:MenuGenerator
  • Neos.Neos:DimensionMenuGenerator
  • Neos.Neos:BreadcrumbMenuGenerator

The existing Prototypes Neos.Neos:Menu, Neos.Neos:DimensionMenu,
Neos.Neos:BreadcrumbMenu` would become pure FusionObjects that build upon those.

Since this adds/renames quite some prototypes i would like to get the team opinion on the big picture first. The implementation would be done separately for the Array* Collection and Menu* prototypes.

2 Likes

I totally agree on that!

As we already talked about this, I mostly agree, but the following:

Neos.Fusion:Object as we generally talk about Fusion objects this is highly confusing. I get where you are coming from. How about (in conjunction with Mapping) we call this Neos.Fusion:Map ?

Additionally Mapping could be a Mapper ?
And Iteration could be an Iterator or even a Reducer if we wanted.

Thanks for pushing this topic! :slight_smile:

I totally agree that there may be better names. Let us wait and look in some days wether even better names pop up.

Thanks for bringing this up.

I very much agree with the renaming of the Array to something more fitting.
But Concatenation also doesn’t feel right for me yet. Reducer and Concatenation sounds so technical.
Maybe RenderableArray or something like that which shows the use?

And like Christian said, don’t use Object for the RawArray , think that will cause lots of confusion :slight_smile:

Regarding the collection I have no problem with the current naming, therefore I’m neutral.

Redoing the Menustuff sounds very good!

Maybe Neos.Fusion:RawArray -> Neos.Fusion:Dictionary will work better.

3 Likes

@christianm Neos.Fusion:Map might work … i kind of like this

I like the suggestion but I agree with Christian: Object is no improvement.

And while we’re at it: I think it would be a good idea if the MenuGenerators would use a dedicated MenuItem (or similar) sub-prototype to reflect the items. Not some magic array

@bwaidelich you mean something like this? Could work backwards compatible if the fusionObject returns itself and implements array_access.

test = Neos.Neos:Menu {
    itemCollection = Neos.Fusion:Dictionary {
       home = Neos.Neos:MenuItem {
          label = 'Home'
          node = ${site}
       }
       impressum = Neos.Neos:MenuItem {
           ...
       }
    }
}

yes, or even

test = Neos.Neos:Menu {
    itemCollection = Neos.Neos:MenuItems {
       home = Neos.Neos:MenuItem {
          label = 'Home'
          node = ${site}
       }
       impressum = Neos.Neos:MenuItem {
           ...
       }
    }
}

Strictly speaking, there’s no Reduce operation (in the sense of an Array -> Any function) in Fusion at the moment. So, Reducer might be a bit misleading, even if the current Neos.Fusion:Collection is a sort of reducer.

But I’d strongly support adding a general Reduce or even MapReduce prototype of course :slight_smile: (and then basing Neos.Fusion:Collection on it).

Since adding Neos.Fusion:Map as better name for Neos.Fusion:RawCollection seems to be a thing we all agree on Neos.Fusion:Reduce would indeed be a nice addition.

Thanks for the feedback so far. I came to the conclusion that the new prototype names should reflect the declarative nature of fusion and thus describe the expected result.

Here are my current favorites:

Neos.Fusion:RawArray      >>  Neos.Fusion:Map
Neos.Fusion:Array         >>  Neos.Fusion:Concatenation
Neos.Fusion:Collection    >>  Neos.Fusion:Iteration
Neos.Fusion:RawCollection >>  Neos.Fusion:Mapping
-- new  --                >>  Neos.Fusion:Reduction 

Regarding the Menu* prototypes i now think we should deprecate them alltogether. The only non trivial one is the dimensionMenu. I hope the new CR will enable flowQuery Operations to access node-variants and make this case as trivial as the normal menus.

What do you think about this?

The only naming that seems off to me is the Concatenation. Don’t have a better name on the top of my head, but at least Concat seems a bit better in my opinion. But would hope there’s a more suiting name.

FYI: I started the implementation in https://github.com/neos/neos-development-collection/pull/2189