*WARNING*: DO NOT IMPLEMENT YET - TO BE DISCUSSED.
Use a more intuitive syntax, where methods are called on the document element being modified instead of the accessors.
The discussion originated from a concern that the syntax {{borrowalsObjectFieldAccessor.add( target )}} was not very clear, especially not to new users. A few solutions were mentioned, one of which was renaming {{add()}} to {{addTo}} or {{create}}, and another was to invert the syntax of accessors, which may feel more "natural".
See https://github.com/hibernate/hibernate-search-6-poc/commit/f07d3c2a5278c8c1baaa32ef803e57d4d6653b79:
This: {code} DocumentElement borrowalsObject = borrowalsObjectFieldAccessor.add( target ); shortTermBorrowalCountAccessor.write( borrowalsObject, shortTermBorrowalCount ); {code}
Would become this: {code} DocumentElement borrowalsObject = target.addNew( borrowalsObjectFieldReference ); borrowalsObject.add( shortTermBorrowalCountReference, shortTermBorrowalCount ); {code}
We may want to do the same for entity accessors, to be consistent.
Note that in order for this to make sense, we would have to rename the "accessor" to a "reference" or some similar term expressing the fact that this object is "passive" by nature (on contrary to an "accessor"). |
|