mardi 27 avril 2021

Suggestion for tech stack that is good for interactive forms?

tl dlr: Looking for a tech stack for a SaaS project where I can efficiently provide users with interactive forms that updates fields as they interacts with input fields.

I have an idea for a SaaS project but I'm struggling a bit on deciding a technology stack. I'm not the most experienced web developer but I come from an OO world so I feel very much at home when I can model stuff with classes. I like to focus on the "core" functionality which is the most important and I want to make sure that I can develop it efficiently. To give a bit of context, the project is a calculation tool which takes numerous inputs and has numerous output fields. A spreadsheet on steroids if you will. Actually, as a PoC, the calculations were done in a spreadsheet and that is what I want to present in a SaaS solution - just nicer.

I'm not set on any particular language but open to hear what language/framework will benefit me the most. What I'm most concerned about is not having to do too much cumbersome work when it it comes to manipulating the model. Whether it being handled fully on the frontend or sent back and forth between frontend and backend. I would like something were I can easily define components/views that represents fields and have the calculations update as the user interacts with the form/inputs. I don't want to replicate models in both frontend and backend.

Just to get an idea of what I've been trying to model, here are some example classes that I've been experimenting with in Java (again, I'm not set on Java as the final language). Don't worry to much about the types. It just to get an idea of how I would like to structurally model the calculation and tie fields together.

public abstract class Field<T> {

    protected final String name;

    public Field(String name) {
        this.name = name;
    }

    public abstract T getValue();

    public String getName() {
        return this.name;
    }
}

public class InputField<T> extends Field<T> {

    protected T value;

    public InputField(String name) {
        super(name);
    }

    @Override
    public T getValue() {
        return this.value;
    }

    public void setValue(T value) {
        this.value = value;
    }
}

public class IntegerField extends InputField<Integer> {
    public IntegerField(String name) {
        super(name);
    }
}

public class IntegerSumField extends Field<Integer> {

    private final List<InputField> fields;

    public IntegerSumField(String name, InputField... fields) {
        super(name);
        this.fields = Arrays.asList(fields);
    }

    @Override
    public Integer getValue() {
        return fields.stream().mapToInt(f -> f.getValue()).sum();
    }
}

public class CalculationSection {
    private final IntegerField input1 = new IntegerField("User Input 1");
    private final IntegerField input2 = new IntegerField("User Input 2");
    private final IntegerSumField output1 = new IntegerSumField(input1, input2);
}

Now this is just a simple example - obviously the real deal has many more fields and sections/sub-calculations. It would be nice to be able to declare a view for CalculationSection and have views for the various Fields being reused - and have the model updated as the user interacts. The calculations should be persistable so some backend has to handle the model.

I'm also looking for SaaS boilerplates (don't mind paying) to get me going - I just don't know what to look for since I don't know which language/framework is best for my use-case.

I know this is quite a mouthful but I've been thinking about this for a while and now I finally decided to ask SO about it - would love to hear your suggestions and thoughts about this.




Aucun commentaire:

Enregistrer un commentaire