I "herited" a lot of Spring Boot code which is basically an asortment of REST Webservices. All those webservices are separated into an interface and an implementation and I find it hard get a grasp of which method is doing what and change an implementation.

The interface usually looks like this:

@RequestMapping(value = "/getfoo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody ResponseEntity<Metadata> getMetadata(
        @RequestParam(value = "Id", defaultValue = "") Long id);

The implementation is basically a copy of the interface:

public @ResponseBody ResponseEntity<Metadata> getMetadata(
        @RequestParam(value = "Id", defaultValue = "") Long id)

The part I consider annoying the most is that the implementation lacks the URL from the RequestMapping and I have to jump back and forth between declaration and implementation. Eclipse provides support to ease this but it is a waste of time.

I consider flattening the design and removing the interface. Is this a bad idea ?

  • 1
    Oof, that's horrible. Absolutely flatten it, the interfaces are gaining you nothing for the overhead.
    – jonrsharpe
    Sep 18 '18 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.