-
Notifications
You must be signed in to change notification settings - Fork 189
Description
When building a full-stack app, I find it frustrating to define basically 3 nearly identical types:
- What I consider the main struct: defining the logic of the type disregarding any GUI/DB needs. This is the struct you'd define normally. This struct would contain only the most basic fields needed to define it "in real life" (e.g. a
Userwill havename,email, andpassword). Methods associated with it would only deal with actions that have to do with what it actually is. - The back-end struct: same as in # 1 but for the database, with the obligatory
idand maybe publicidfor associations with other entities. Methods with this one would be CRUD. - The front-end struct: Again, same as # 1 but for the GUI. User-facing with some additional checks and validations.
As suggested in this Discourse topic, one way forward is to wrap the business struct (type # 1 above) with a wrapper struct that includes all the missing fields needed for the DB or the GUI. Currently, I think the pipeline to make this convenient is missing. For instance, in issue GenieFramework/Stipple.jl#47 a convenience wrapper for custom types is missing on the GUI end of things. On the other end, DB, the same problem exists: I can't SearchLight.findone(MyCustomType, field_name = field_value).
Right now, I need to basically replicate my custom type for each tier and add the missing fields for the two tiers (e.g. id for the DB). Or alternatively, have a business type that includes fields that "pollute" it's actual function (e.g. the id field has nothing to do with a user being a User on its own right).
This feels like a magnificent opportunity for Genie to be the first framework to solve this duplication of code. Imagine a framework where full-stack developers only need to define the business structs and their methods, while the front and back end automagically follow suit! This might be a high order, but if there is a way to make this happen, then the appeal to use the Genie framework should be huge.