Skip to content
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

Consider Object Approach for DB Sources #18

Open
dr-rodriguez opened this issue Feb 14, 2020 · 2 comments
Open

Consider Object Approach for DB Sources #18

dr-rodriguez opened this issue Feb 14, 2020 · 2 comments

Comments

@dr-rodriguez
Copy link
Owner

Instead of treating everything like a dictionary, perhaps it would have been better to implement Python Classes for the various types of objects we are considering- Sources, Fields, Entries, Values. Then I could have methods that properly format it to/from JSON and that independently validate without having to rely on crawling through a dictionary. Could make local searching more complicated, but I would favor rewriting it with this data model in mind as it would make things more manageable as the API grows in complexity.

@eteq
Copy link
Collaborator

eteq commented Feb 21, 2020

My initial instinct is that this adds a lot of complexity with questionable value for the user. In the end the user is really going to want Quantity and array objects anyway, so I think it's better to focus the user-facing API on getting quickly to those sort of objects.

That said, if we're thinking of this more as an "implementation detail", or using this as a way to implement a relatively light ORM-like model, I could see that. But I think we then have to be very careful to not spend too much time thinking of this as the "normal" interface.

@dr-rodriguez
Copy link
Owner Author

I agree that the final output that users get should be of type array, Quantity, or similar. In my mind, this is meant more as the low-level API behind the scenes to facilitate queries, validation, etc.

Currently, the (local) database is implemented as an array of dictionary objects and while dictionaries are very powerful, I feel that they also have some drawbacks. A lot of the code is wrangling with these dictionaries to get the functionality we want out of them and enforce our validation, something that might be possible to simplify by having some enforced structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants