DEV Community

Cover image for New Web Framework?
Gunnar Gissel
Gunnar Gissel

Posted on

New Web Framework?

I've been working on a web framework, but before I go any further, I thought I should check to see if anyone else is interested in the type of framework I'm building.

Web developers build all kinds of things, but one of the most common things they build are forms. Order forms. Email signup forms. Business process forms. Forms to enter data from a fax. All kinds of forms.

These kind of webapps usually have some html, a custom webservice, some middleware to do business/database stuff and a database.

I know I get tired of writing the webservice and the middleware boiler plate again and again. The forms change a little, and you need to either write a fresh webservice and fresh data access objects, or make your existing webservices even smarter.

What if there was a tool that could inspect your html pages and generate a backend for you?

I think something could inspect a form, make sensible default table and column names and web services to populate them. Done right, the tool could make something that would require very little manual tweaking. I think a tool like this would let web developers put time into what they care about (delivery quality products and making money) as well as what the customers care about (having good looking web page that do what they want).

Would anyone else be interested in a tool like this?

Discussion (24)

Collapse
tux0r profile image
tux0r

I prefer to write code. I don't trust generated code.

Collapse
cjbrooks12 profile image
Casey Brooks

I don't trust generated code either in most cases. It's too easy for scaffolds to fall out of date or require a lot of work to make the generated code do the additional stuff you need.

However, Java's annotation processing API is really nice for compile time code generation, so you know it is always up to date and works exactly as it should. Code generation that gets destroyed and recreated continually can be quite invaluable.

In my opinion, code generation can work but it shouldn't be static generation, only done once. It should be part of your build process.

Collapse
_pankajc profile image
Pankaj

Is this dynamic code generation responsible for slower server start ups in spring boot? I'm learning spring boot right now and love it so far except for the slower server start ups.

Thread Thread
tux0r profile image
tux0r

Probably. Everything that has to be calculated for each new visitor inevitably leads to additional latency.

Thread Thread
cjbrooks12 profile image
Casey Brooks

I'm not too familiar with Spring Boot, but code-gen would make the compilation step take longer, not the server startup. Java code generation libraries (such as Dagger and Butterknife which are common on Android) actually dramatically increase application startup times, because all the hard work has been done at compile-time.

Taking Dagger as an example (dependency injection), the generated code doesn't require Reflection as a runtime-library would. It looks for @Inject annotations in your code, finds the @Modules which provide those dependencies, and writes new Java source files to create the object for you. Super fast, no reflection required. Spring Boot does runtime injection, and so uses Reflection to find the @Inject/@Autowired annotations, and then uses Reflection to call the constructor or set the fields as necessary, which is known to be slow. This is in addition to the many other things Spring is doing on server startup (classloading, resolving routes, connecting to databases, etc.).

Thread Thread
stealthmusic profile image
Jan Wedel

A spring boot app with 1000s of beans and component scanning still starts in 1-2 seconds. Most of the startup time is consumed when using Hibernate and flyway eg.

Collapse
monknomo profile image
Gunnar Gissel Author

Maybe I've spent too much time in the Java world with Spring and Hibernate, but I don't mind generated code. The main thing is to always be able to regenerate it, imho. Never modify it, and don't ask it to do anything it isn't designed for

Collapse
quii profile image
Chris James

Probably something you're not thinking about is the UX.

Too often websites mirror their database in terms of "here is a CRUD form that maps around a table in our db". That's the way it is for a lot of websites but a lot of research is showing how it's poor UX

Have a read about task based UIs. Rarely does someone want to read a form and edit one field, or two fields. They want to perform a meaningful business action which should have a specific form for it.

The reason I mention this is that it probably doesn't fit too well in your model. Not to discourage you! You're right that a lot of websites are how you describe, but it would be great it if we could move away from that!

Slight nitpick

some middleware to do business/database

"Middleware" generally should not be doing any business logic. I would not expect my middleware to be responsible for saving the form entries into databases.

Good luck!

Collapse
monknomo profile image
Gunnar Gissel Author

I mostly implement task based UIs at the day job, but baby steps. I'd rather see if there is interest in a framework that can be given a form and create a backend first, before a framework that can be given forms, and create a backend, and then manage the finite state machine inherent in task management.

Collapse
monknomo profile image
Gunnar Gissel Author

middleware is perhaps the wrong word. I mean the "middle layer"

this:

UI
Everything in the middle
Database

Collapse
cjbrooks12 profile image
Casey Brooks

A couple links you might be interested in:

Netlify Forms - any JAMstack site hosted on Netlify has exactly what you described built it. They will find forms in your site with the data-netlify attribute and automatically start collecting its submissions in your dashboard for you. You can set them up to post to any webhook on all submissions so you can do whatever you need with the data after that.

October CMS - A newish php framework, built on top of Laravel. A big feature is that it makes the development experience almost trivially easy for common use cases of web server development, especially in building backend forms. It is amazingly powerful, while being incredibly easy to work with complex data and DB relations. Most forms, even really complex forms with many fields and related resources, can be implemented almost entirely in declarative code models and YAML config files.

Collapse
monknomo profile image
Gunnar Gissel Author

Netlify looks interesting and something like what I'm thinking of.

Collapse
jasonbradley profile image
Jason Bradley • Edited

The closest implementation I've seen to solving this type of challenge was utilizing Django + Django Rest Framework.

After defining your models (docs.djangoproject.com/en/2.1/topi...) you can utilize the Django admin interface (docs.djangoproject.com/en/2.1/ref/...) for handling CRUD type behavior.

On the API side you can rely on your previously generated models to build out a CRUD API.
(django-rest-framework.org/api-guid...)

You can also generate your web forms from the models as well.
(docs.djangoproject.com/en/2.1/topi...)

Collapse
monknomo profile image
Gunnar Gissel Author

Django is close to what I'm talking about. Particularly their admin pages.

Collapse
copleykj profile image
Kelly Copley • Edited

Seems strange and a little overly complicated to define your front end code and have your back end code generated from it instead of vise versa.

This is especially the case when things like GraphQL or SimpleSchema allow you to define how your data should look on the backend and packages like uniforms take that definition and create your forms from that.

Collapse
cjbrooks12 profile image
Casey Brooks

While this might not be the most efficient for developers, it could be huge for non-developer content managers. Imagine being able to build a website for a client, and they can manage forms with real, structured tables themselves without needing to go to the developers for every new form they need, and without resorting to "Form-builder" plugins which typically use key-value DB schemas for form submissions that are difficult to query or write reports for.

Collapse
monknomo profile image
Gunnar Gissel Author

That is who I'm thinking of. CMS folks, web designers, regular designers, people with a flowershop and a nephew who is 'good at computers'.

Generating UIs from the backend typically involves a lot of fussing with yaml or xml or json in lots of different files and some light coding. Big steep slope to climb.

Collapse
asamolion profile image
Muhammad Osama Arshad

I've been making web forms and calculators for my clients for quite a while now. I think such a tool would be great. I would also be willing to chip in if possible.

However, many clients require web forms that don't interface with a back-end, an example of this would be pricing calculators.

Do you think your tool would be of help in such a case?

Collapse
monknomo profile image
Gunnar Gissel Author

The tool I have in mind would not be useful in that case. For the case you are describing, I think a well made static website would be the best tool.

Collapse
cdsaenz profile image
Charly S. • Edited

It's always interesting to have code generation tools. I was thinking the other day about that. To connect to a database and generate UX and basic code. Lots of mistakes could be avoided. Did it in other languages before but for my own usage. Problem with what I've seen in the market is that they force you to use some functions of their own. I'd love to see what you come up with.

Collapse
xdracam profile image
Cameron

I'd need an easy and transparent way to access the generated API myself - for those sudden special requirements that don't work with defaults and weren't planned in - without damaging readability.
Otherwise the framework would prove too inflexible for productive use and would fail fast

Collapse
ben profile image
Ben Halpern

I think this could be useful if it fits in just right. Would this be designed to sort of fit in as a JAMstack utility tool? Would want more details.

Collapse
monknomo profile image
Gunnar Gissel Author

JAMstack is a really useful term that comes close to what I'm imagining. My quibble is that I'd like to get away from editing so many templates for simple applications. Sometimes, I just want to make the app, rather than make the templates to make the app.

In my minimalist, non-JAMstack conception, I picture a utility that you feed a form to. It outputs a Dropwizard application. When you run the application, you may go to an admin interface that walks you through the configuration you need to do (credential setup, where is your database, what's the address). From there you can create the initial database structure and have an administrative view of the data you've collected and your api docs. It also would host the form and provide an api.

In my maximalist, possible SAAS conception, I picture a service you give your form to you. It asks you the configuration quests, then creates a storage bucket and a lambda, hosts the static file and gives you a useful admin interface. Explains how to integrate into the rest of your site.

Collapse
monknomo profile image
Gunnar Gissel Author

Thanks everyone for commenting, I really appreciate all the different perspectives and suggestions.