jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: Annotations CoC [Was: Convention Over Configuration]

From: Bill Burke <bburke_at_redhat.com>
Date: Tue, 22 Mar 2011 14:33:01 -0400

On 3/17/11 5:06 PM, Adam Bien wrote:
>
> On 17.03.2011, at 11:40, Marek Potociar wrote:
>
>> Hello *,
>>
>> FWIW, here's my take on the annotation CoC topic so far:
>>
>> - Resource method annotations (@GET, @POST ...) cannot be made optional unless we decide to severely break BW
>> compatibility with JAX-RS 1.x spec. Also, other than reducing the amount of code in the most simple cases, I do not
>> really see the more significant benefit of such change. Thus it seems to me, the cost/value ratio in this case is too
>> high. I would not support this change.
>
> o.k - it would be a minor optimization either.
>>
>> - As for @Path annotation, I would not want to make it optional either, because I am concerned about the readability and
>> maintainability of the code below due to the potential side effects[1]. To workaround the mainainability issues, we
>> would need to specify a lots of rules, which IMHO compromises the main reason of CoC as it violates the KISS principle.
>
>>
>> - As for specifying the default value of the @Path annotation, I can see certain limited benefit in the early
>> prototyping phase of a project. And since it is not breaking BW compatibility, I'd be willing to consider a proposal
>> that would be aligned with principles stated in JSR250. Being the part of the same umbrella specification, we should
>> converge with related specifications rather than diverge from them.
>
> I cannot agree with that. JPA, EJB work also with CoC and there are no issues. The mechanics are even similar. E.g. in JPA the class name gets mapped to a table and an attribute to column. Annotations are optional, except @Entity.
>
> IMHO readability of the code is the best without any annotations :-)
>
> Putting the name of the method inside @Path would violate the DRY principle.
>
> *DRY + CoC should be a main theme across all specs in Java EE 7*
>

I talked to Adam at TSSJS and he convinced me that limited support for a
default value for @Path is a good idea. IMO though, the rules have to
be ultra-ultra simple. JPA CoC works because the mapping rules are very
very simple. Same has to be for a default @Path value.

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com