-
Notifications
You must be signed in to change notification settings - Fork 149
Separate validation from metadata retrieval #497
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
Separate validation from metadata retrieval #497
Conversation
0f67bc2
to
2a7a06c
Compare
I would be ok with this but a method that depends on another is always a sign of clunkiness to me. The question to ask is: would you ever need to get metadata without validating the manifest first? I think the answer is no. If that's true, you could change the class to this:
The only downside is it conceals the fact that some potentially costly validation is taking place inside the constructor. I think the upside of making the r+wc |
It's all swings and roundabouts! I was working on the basis that the constructor shouldn't do too much, but I see what you're saying and I think you're right - it's probably a touch cleaner your way on balance. |
@kumar303 ok this is ready for another look. |
var result = new ManifestJSONParser( | ||
json, this.collector).getMetadata(); | ||
return result.metadata; | ||
var manifestParser = new ManifestJSONParser(json, this.collector); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be let manifestParser...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm tending to use let
when needed. Inside a function like this there's no difference between var
and let
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...and even then I forget to sometimes - old habits die hard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever works. I've been trying to always use let unless var is needed. My rationale is that a code refactor might introduce a new block (a line down from your closure, for example) that could leak the variable.
r+wc |
2ad4d5a
to
7690dec
Compare
…rate Separate validation from metadata retrieval
Fixes #496