brainfoolong / form-data-json

A zero dependency, cross browser library to easily get or set/manipulate form input values as/from a json object.
https://brainfoolong.github.io/form-data-json
MIT License
60 stars 10 forks source link

FR: It seems excess to do `new FormDataJsonOptions` #11

Closed KES777 closed 3 years ago

KES777 commented 3 years ago

It seems too verbose to write each time: new FormDataJsonOptions. To pass values we could just pass a simple hash. If this is required by code then this hash could be turned into FormDataJsonOptions internally

also these methods fillFormFromJsonValues, formToJson could be simplified to: fillForm, readForm or toForm, toJson. Is there any reason for long typing?

unsetAllInputsOnFill -> clearForm. +implement resetForm. Different is that clearForm - clears all inputs, resetForm set default form values if there is not corresponding value at supplied hash.

Thank you

brainfoolong commented 3 years ago

As for the naming of the functions, it's a design decision made in the beginning. I tend to use verbose naming of functions, as it as clear in the moment you look at it at the first time, without knowing anyhting else. So, changhing to root function naming here is not a thing a want to. Same goes for existing options.

As for the shorthand for new FormDataJsonOptions - This could be a thing, for sure.

As for the "reset" idea, this sound interesting.

KES777 commented 3 years ago

Agree with you that long names are good for reading. But in any case for each option/function I must read documentation to understand details. So actually it has no matter it would be named as two words or five words. In any case developer will read documentation.

So at long term developer must spent his time forever by typing long words without no benefit. (no benefit - because he read documentation in any case). Good names should be 5-10 chars long.

But this is just my point of view. Thank you for explanation

brainfoolong commented 3 years ago

Thanks for your point of view. I understand your opinion as well.

brainfoolong commented 3 years ago

A new pre-release does exist. https://github.com/brainfoolong/form-data-json/releases from branch https://github.com/brainfoolong/form-data-json/tree/v2-dev - Maybe you give it a shot. I took your feedback into consideration and refactored the hole thing as it has a few flaws that i didn't liked.

KES777 commented 3 years ago

Thank you for release, it works like a charm.

Thank you for renames, I like them.

For another notices I open different issues.