Have you had that feeling that you have to write too much code to build simple functionality? Some things just feel repetitive, they feel you should be not have to write them yourself, instead a framework should make your life easier.
Recently I’ve been building a project in Java/Spring, and after some time I started wondering about alternatives and how to build the same functionality with less code.
There is lots of alternative frameworks and multiple ways of building rest endpoints in Java/Spring.
- Building the controller/service/dao layers manually in Spring ; https://spring.io/guides/tutorials/bookmarks/
- Using spring-data-rest to export your spring-data repositories ; https://spring.io/guides/gs/accessing-data-rest/
- Groovy/grails RestfulController ; https://examples.javacodegeeks.com/jvm-languages/groovy/grails/grails-rest-example/
- Python/django django-rest-framework ; http://www.django-rest-framework.org/tutorial/6-viewsets-and-routers/
Below some abbreviated examples of how a simple rest endpoint looks for each approach. To actually run the examples, you’ll need check out the tutorials mentioned earlier. My goal here is a quick comparison of how you do things in each framework.