chkal / mvc-spec-migration-test

0 stars 0 forks source link

Convention over Configuration #24

Closed chkal closed 9 years ago

chkal commented 9 years ago

Original issue MVC_SPEC-24 created by Santiago Pericas-Geertsen:

From "Rodrigo":

-- 2) I like the initial code, but from the beginning we could assume some defaults (conventions) to avoid a lot of annotations defining a simple hello world on MVC. One of the things I like on VRaptor is that it takes convention over configuration. So do other frameworks. For instance, the ConversationController class look like:

@Path("converse") public class ConversationController {

@GET @Controller @Produces("text/html") @Path("tellme") public String tellme() { return "tellme.jsp"; } }

Besides being very verbose (10 simple methods would require +/- 70 lines), the user must to remember about adding @Produces, etc. User must to know much about spec to start using it.... IMO the controller could just look like this:

@Controller("converse") public class ConversationController {

@GET("tellme") public String tellme() { return "tellme.jsp"; } }

chkal commented 9 years ago

Comment by Santiago Pericas-Geertsen:

I tend to agree with this report regarding CoC. In MVC, we've tried to allow annotations like @Controller and @View at the class level to reduce duplication. All the other annotations are from JAX-RS, and there's already an issue filed for that:

https://java.net/jira/browse/JAX*RS*SPEC-71