[naming] Node Components and UI Components

We discussed this before and kind of came up with these two distinctions, but it was clear in the days afterwards that this still wasn’t ideal.

On the node side, the word “component” is the “correct one” since we’re using the entity-component-system model (well, if we do use it).

On the UI side, every single web/app developer considers the word “component” to refer to widgets and layouts that are modular, reusable and composable.

I think since our target market is the web/app developer community, we should avoid confusing two central terms, give priority to the UI side, and find an alternative name for “node components”.

Here’s a Wiki article on the Entity Component System model.

From Miriam Webster thesaurus:

component

noun
Synonyms and Antonyms of COMPONENT

one of the parts that make up a whole <each set is composed of several distinct components

Synonyms building block, component, constituent, factor, ingredient, member
Related Words basis, part and parcel; detail, item, particular, point; aspect, characteristic, facet, feature, trait; division, fragment, particle, partition, piece, portion, section, sector, segment; subcomponent
Near Antonyms aggregate, composite, compound, mass; entirety, sum, summation, total, totality; admixture, amalgam, amalgamation, blend, combination, intermixture, mix, mixture
Antonyms whole

I actually love the meaning of constituent (1. any one of the people who live and vote in an area : a member of a constituency, 2. one of the parts that form something) but of course it’s too long :confused:

There were some others I liked too but let’s open it up (and not be restricted to synonyms).

Perhaps one could adorn a Node with an Augment or a Decorator.

Facet is also nice.

It’s worth noting that Decorator was Famous’ original choice of name.

I’m partial to the term ‘Node’ for objects on the Scene Graph. Everyone is using the word Component these days to mean a lot of things. Angular 2 has a Component Decorator, Polymer is leading the charge with Web Components, React has Components. It may be prudent to give our Components a different name, so talking about them is easier when speaking in context with other frameworks. @oldschooljarvis I like the terminology of Decorating a Node.

Should we maintain a baseline DOMComponent? If so, does that mean we need to maintain a baseline GLComponent? I’m afraid of going down the same path as Famous with the latter and think that an integration with Three.js or Babylon.js is the way to go there. Maybe if we do maintain a DOMComponent (which I predict ~99% of developers will use), it would serve as an example for other Components. SVGComponent, WebComponent, etc.

We can make a Component that receives updates from a Node and then extend that Component to make others with ES6 Classes. For instance, all a DOMComponent would really need is the transform data from a Node converted to a 4x4 Matrix. IMHO its no use decorating a DOMElement any further than that, just let developers use the Element.prototype they are familiar with. Whatever is handling the updates can just extend the Element.prototype.

var ulNode = new Node({
 position: [0, window.innerHeight-20,0]
});
var ul =  new DOMComponent('ul', ulNode); //add ul to DOM
var liNode = ulNode.addChild();  // retains position of parent node
var li = new DOMComponent('li', liNode); // create an li
li.classList.add('class1','class2'); // add classes to it

The idea of extending Element directly is interesting. This indeed would make it easy to do DOM-related things (even something like $(ul).whatever() with jQuery). If the API is designed well, relevant DOM parts of the API implementation are on the UI thread, and other parts delegated to corresponding worker instances.

The question is, if we have a base class for components, f.e. NodeComponent, then how do we extend from both NodeComponent and Element? Perhaps DOMComponent would be a special case that could extend from Element, then we’d mix NodeComponent’s prototype into DOMComponent’s prototype. Other components, like MeshComponent, would just simply extend NodeComponent since browsers don’t have any special classes for those (yet).

I’m still okay with just having a reference on a DOMComponent (that extends NodeComponent) to a real DOM element, as in domComponent.el (which would be fine if the public API always lives in the UI thread (it always should IMHO)).

I added a link to a wiki article on the entity-component-system model to your original post @gadicc.

1 Like

At first I was confused by the term Component in famo.us mixed-mode. But after a while I got used to it and after reading that it was derived from the Entity Component System, it actually really made sense to me.
Then again, I was confused with the term “modifier” in v0.3 initially as well… I think it’s fair to say that most users of the API/engine will be web-developers (and not game-engine pros), so we should either choose a name that makes sense to them or educate them. In this particular case I would personally go for the latter option. Primarily because they are likely not familiar with this approach of extending objects, and they should be well aware of these concepts when working with the API. And having a name that corresponds to the model that is used is beneficial to the process of understanding. I think coming up with a custom name doesn’t benefit anyone (remember “Surface”?).

So to recap, I think there are two general lines of thought here:
a) Prevent confusion
b) Promote understanding

Both are very valid points and ideally we adhere to both of them. I do think there is already confusion with the naming in this industry, regardless of what we would choose, so I opt for option B.

2 Likes