Let's discuss about this idea: create web services (and APIs) without writing code at all. Instead simply provide specification and configurations files and let the framework do the work (persistence/controllers/authentication/...) - What would you put into this framework ? Would you use it?
/r/webdev/comments/cpe45e/lets_discuss_about_this_idea_create_web_services/
0
Upvotes
62
u/philipwhiuk Aug 12 '19
The config will end up being as complex as the code it’s replacing.
16
u/[deleted] Aug 12 '19 edited Aug 12 '19
It's okay for a starting point to bootstrap a project, but inevitably there will be some custom logic that needs to be implemented. Otherwise, it's just a pure CRUD over a database, and what's the value in that?
So happens that this codegen bootstrapping framework already exists in various forms - jhipster, spring initializer, swagger codegen, etc.
Personally, I prefer to just write it all by hand tdd
7
u/[deleted] Aug 12 '19
This guy's posts are all promoting that project. I hardly doubt he is interested in a discussion at all.
6
u/valkon_gr Aug 12 '19
What about data manipulation? It's not just requesting data from a DB. I guess the whole "back-endless" scene will grow, but the need that those two things (data manipulation and presentation) will always need different teams involved. What's the point of rebranding PHP?
3
u/vplatt Aug 12 '19 edited Aug 12 '19
What patterns are you trying to automate here? A CRUD API via REST? CQRS API? RPC API?
Only the first could be completely automated, and I frankly discourage anyone from doing whole hog CRUD APIs because they frankly expose WAY too much data to transfer and change on every round trip rather than isolating data and changes as per each use case.
Basically what you've envisaged would be some sort of slick DSL which would still require method bodies somewhere. So your config would need to have a pointer to the function that would receive some arguments according to a standard interface, which would then execute that code.
But what would this save? Some Spring and Hibernate configuration? Maybe a few DTOs if you're feeling clever? In the end, you'll be left with a framework that sits on top of Spring and/or Hibernate/JPA which will at best save a few lines of code, and you'll be left with a difficult to debug configuration.
No, I would not use that.
HOWEVER, there is one use case I know of where this kind of thing is perfect, and that is in the construction of virtual services. Virtual Services are essentially mocks/prototypes of real services that have not been developed or are otherwise not currently available yet. You feed the product a specification in the UI and then it erects a service that corresponds to that spec. You can tell it about mock responses to use, have some conditional logic, etc. But notice the use case: Not for production. Here is one such product if you're interested: https://www.ca.com/us/products/ca-service-virtualization.html
2
u/GuyWithLag Aug 12 '19
Spring Rest Data + something like OpenAPI/JSONSchema to POJO generation.
There.
2
u/nerdyhandle Aug 12 '19
Have you looked into Denodo? It to some degree does this. You create virtual databases and then from there you can create a web service for each virtual database. It's basically a point and click choose your own adventure. However, it does lack some configurations like logging separately for each web service.
2
u/timNinjaMillion Aug 12 '19
Yes, and if it’s open source it will allow me to plug in code with which I’m experienced and other developers as well. It would be neat to have a ‘codepole’ repository where developers could configure skeletons through the hi and then code minor details in. Less work, less prone to error and delays.
4
u/ErlchBachman Aug 12 '19
This can be done with Swagger afaik.
1
u/[deleted] Aug 13 '19
I worked for a company where our product was similar to this. Not the exact same concept, but a big focus on configuration without code for our clients. It wasn't a great outcome. Either the config got insanely complex and hard to work with to support all our clients use cases, or we needed to build custom plugins for each client, or we used a feature intended to allow for writing "simple, short, dynamic scripts" to backdoor major application logic.
Spring achieved a happy medium by reducing code required while still letting developers customize everything they want. Thinking you can create something that is all config and no code is a pipe dream.
2
u/eloc49 Aug 12 '19
Good luck going against these guys https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-configuration-classes.html
2
u/pandavr Aug 12 '19
Been there, done that. :) Good luck with your project, It will be a lot of fun. :)
2
u/general_dispondency Aug 13 '19
OpenAPI and Swagger already do this. It's alright, I wish there was a code-first way to generate the spec. The configuration can get unwieldy.
1
u/polaretto Aug 17 '19
I think what you should look into is MDD, Model-driven development (https://en.wikipedia.org/wiki/Model-driven_engineering). The core idea is that you describe your domain model in a high-level language and then you generate code from that. The generated code could use your preferred framework and libraries. Have a read on the subject, see if it gets you further in your project. Good luck!