cejug / hurraa

Opensource project to resource management
GNU General Public License v2.0
16 stars 18 forks source link

Simple injection usage and no more @Deprecated annotation #153

Closed helio-frota closed 3 years ago

helio-frota commented 10 years ago

From:

@Controller
public class IndexController {

    private Result result;

    @Deprecated
    public IndexController() {}

    @Inject
    public IndexController(Result result) {
        this.result = result;
    }

    @Path("/")
    public void index() {

    }

}

To:

@Controller
public class IndexController {

    @Inject
    private Result result;

    @Path("/")
    public void index() {

    }
}
paulojribp commented 10 years ago

The first one @eprogramming was discussed on the beginning of the project that it keeps the dependencies more clear and more useful for unit testing

efraimgentil commented 10 years ago

Yeah that was decided in the beginning, unfortunately CDI still have this problem with default constructors, but with the injection in the controller is easier to test and create mocks, so i kind of liked it

paulojribp commented 10 years ago

@eprogramming whats mean this Closed? Will keep constructors or injection on attribute?

helio-frota commented 10 years ago

hi @paulojribp good catch, i closed this. well i'm going to use injection on attribute and wait / maybe research better approach for the tests.