KristofferStrube / Blazor.FileSystemAccess

A Blazor wrapper for the File System Access browser API.
https://kristofferstrube.github.io/Blazor.FileSystemAccess/
MIT License
327 stars 39 forks source link

Code readability suggestion #13

Closed Sean4572435243 closed 2 years ago

Sean4572435243 commented 2 years ago

Since I expect this library will be very important, I hope you don't mind if I'm a bit pedantic. I see an inconsistent pattern so I wanted to highlight, for example, with FileSystemCreateWritableOptions(bool) and it's imposed constructor, when using this function in code, you end up with

new FileSystemCreateWritableOptions(false)

but the false is non-descriptive, whereas an example of a non-constructor variation looks like

new FileSystemGetFileOptions() { Create = true }

very self-explanatory.

If constructors is your preference, maybe use enums instead of base types?

KristofferStrube commented 2 years ago

Great suggestion. Thanks for the feedback on code quality which is always appreciated. I agree that it would look better if it was not a part of the constructor for the option both for consistency and readability. I will go through all option types and check that they only parse parameters through the constructor if the property is a required field.