Created
December 2, 2013 22:37
-
-
Save jdiez17/7760368 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In your snippet, sync and async are functions. In mine, they are arrays of functions which can raise exceptions. The idea behind this is to remove code duplication. If sync() was a function, it would look something like this (https://gist.github.com/jdiez17/7760198). | |
Even though the idea of the functions in `sync` is to operate on files (in the disk), it doesn't mean that they're designed "around the idea that input file is converted to output files". A function that would validate GIFs/MP4s/whatever would a call to a command whose output is based on a file in the disk. | |
A major disadvantage of passing the Redis file object to all the functions is that each function would have to figure out the path in the file system, which leads to more clutter and code duplication than in the gist I linked. | |
For operations that require storing information on the database, passing the file path to the function is not enough: that's the use for the `extra` function (probably not the best name). Hell, for all I care, I could make it so it calls all the functions in the class with the redis file object. But `validate` would be better implemented as a function like those in `sync`. Then you could have something like this: https://gist.github.com/jdiez17/7760345. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment