Oliver Lietz wrote
> On Saturday 08 April 2017 14:44:55 Carsten Ziegeler wrote:
>> Oliver Lietz wrote
>>
>>> On Thursday 06 April 2017 21:59:34 Julian Sedding wrote:
>>>> The configuration property "user.default.mapping" should be called "
>>>> use.default.mapping", or maybe rather "default.mapping.enabled" to avoid
>>>> typos and confusion.
>>>
>>> We already messed up property names in component configurations (incl.
>>> typos), but as Julian opened that topic here are my € 0.02: use dots to
>>> create a (hierarchical) structure and camel case or snake case to
>>> compound separate words – like logging configs in any application, e.g.
>>> Tomcat
>>> https://tomcat.apache.org/tomcat-8.0-doc/logging.html (->
>>> useDefaultMapping or default_mapping_enabled)
>>
>> Avoid camel casing :) With the new component property types of R7 camel
>> casing can cause in some cases a little bit of trouble. We ran into this
>> while defining annotations for the http whiteboard which unfortunately
>> in some cases uses camel casing.
> 
> Really? Can you point me to an example or elaborate on the issues? I would 
> have expected minor issues with snake case due to dot to underscore mapping 
> but none with camel case.
> 
It's not a major issue - everything works, but R7 allows you to define
component property type annotations. These are the equivalent to the
@SlingServlet annotation we had in our SCR annotations. So basically you
can define your own annotation being used by other component developers
to add properties. This works with camel casing.

However, you can also define a single value annotation which has
slightly different key name mapping rules. For example, if you have the
property "servlet.asyncSupported" you can write such an annotation ASync
having a field like:

    boolean servlet_asyncSupported();

and then use it to annotate your component

 @Async(servlet_asyncSupported = true)

Now, you can convert the above into a single value annotation:

boolean value();

so you could do:

@Async(true)

However in this case the information about the property name is lost and
then the class name is used. And in this case camel casing is used to
insert dots, so an annotation name of @AsyncSupported results in the
property being named "async.supported".

I hope this makes it a little bit clear. So in short camel case is no
problem, but it might create some annoyance down the road. Avoiding it
in the first place is imho a good thing.

Now, if you want to further discuss how these things work in R7, please
let's move this off the Sling dev list.

Regards

Carsten

-- 
Carsten Ziegeler
Adobe Research Switzerland
cziege...@apache.org

Reply via email to