-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unified data syntax #365
Comments
(crosspost from #305, but went more in-depth on my ideas + added some stuff.) Here are some ideas for the UDS type:
And here are some ideas for UDS syntax:
Here is pretty much how (I think) it should work:
At this point it's basically just flexing lol.
And pretty much anything else you could possible think of. Here's a few definitions for different types: Arrays (using integer arrays in this example)
Decimal
Hex Color
Java Color Object
Random Booleans
|
I think the core difference in your proposal is that substitution definitions are separated from the templates, and substitutions cannot be parameterised. (Oh, and you suggest the use of for loops, which I had not completely thought out yet in my design.) I think that the main disadvantage of having users create substitutions is that while it is less verbose, it is more difficult to understand because users first have to define all the substitutions they want to use, and then insert those into the template. With my proposal, the substitution definitions are inlined into the template. This may result in longer template strings, but this issue can be resolved by allowing users to use templates in other templates, using loops, or using other constructs. Whether the syntax is |
I just feel it might look quite a bit messier. Also, by default, the plugin would come with a whole bunch of different things already set up, which the user can then fine-tune. For example: Int[base=16, min=0, max=16777215, paddingChar=0, minChars=6] is how you'd write the Hex Color template. Int[min=0, max=9999].Int[min=0, max=9999, paddingChar=0, minChars=4] is how you'd write the Decimal template. So I feel like it can get quite messy if you have a few variables or many parameters. But in the end, it's up to you. (Also, I feel like it's actually easier than having these magic key-value pairs that you have no docs for. Whereas, it'd be comparatively simpler to explain how the substitution works to someone.) As for |
That's a pretty good argument. To alleviate that issue, I think there could be a small wizard of sorts. No need to manage the defined types, but still an easy interface to build types with. I'll have to look into that. Either way, I'm going to experiment with the solution before it's rolled out, nothing is final yet. |
A unified data syntax (UDS) allows expressing any sort of random data (strings, integers, words, phone numbers, coordinates, arrays, etc.). The existing schemes for any data can be converted into a UDS string, which can then be parsed to create random data. This is somewhat similar to "inverting" a regex (i.e. generating a random string that matches a regex), except that the regex syntax is not well-suited for this problem (no native support for ranges, hard to read, dictionaries result in very long strings).
Instead of giving each data action a
generateStrings
method, each scheme can be compiled to a UDS string which has the#random(Random)
method to instantiate a random string that matches the UDS.This system will pave the way to creating arbitrary new data types, and in particular will allow users to create their own data types. It will also make it easier to add many presets that do not necessarily match any particular data type, but without cluttering any menus. Note that this issue is not about implementing new data types; the goal here is only to introduce the UDS.
Currently, I envision UDS to be similar to the string representations of Kotlin data classes, except that default values can be left out. For example, to create an integer in the range
[0, 15]
, the UDS would beInt[min=0, max=15]
. To generate two integers in different ranges with a dash in between would then beInt[min=0, max=15]-Int[min=5, max=15]
. Naturally, it should be possible to escape this syntax to allow users to insert literally the stringInt[min=0, max=15]
; and spaces should be ignored (except in strings).Other native types should be
Dec
(decimal),Str
(string),Word
(word),Time
(to insert current time?), maybeUUID
if this one cannot be represented with the other types.I should start with a basic syntax. After this issue, no new functionalities are directly exposed to users; this issue does not yet give users the ability to insert new data types.
The text was updated successfully, but these errors were encountered: