I believe the inputs are already appropriately escaped by passing them through `sql.Identifier`. I have added a comment in the gist about this as well.
816 karma · joined April 7, 2016
I believe the inputs are already appropriately escaped by passing them through `sql.Identifier`. I have added a comment in the gist about this as well.
The reason why this is often possible, is that it's _less_ work to start with compared to adding in the layers...
... and then when unexpected requirements turn up, there is less complexity to deal with, there are fewer layers to work/hack around, and refactoring those that _are_ there to be more suitable to the current set of requirements is often easier, and so more likely to fit into time constraints.
I like to think of it as:
> Just about everything is cheaper than the wrong abstraction
(With a clear nod to Sandi Metz)
Agreed that similar behaviour to the examples can be achieved in different ways.
The main aim of FifoLock is to provide a (mini) framework for writing more complex locks. The examples are deliberate in that they show how to create more familiar locks, as an attempt at a gentle introduction to the class.
Also, this actually came out of writing https://github.com/michalc/treelock, which uses FifoLock with a lock that has 4 different modes (as opposed to, for example, a read/write lock that has 2), which is the sort of case where I think FifoLock is particularly useful.
Also, I'm not sure if the example you give of the read/write has the same semantics as the meaning of read/write lock in the examples. For example, it looks like the version here, using asyncio.Lock(), wouldn't ever allow multiple readers, while the one based on FifoLock would, as long as there is no writer.
edit: tweaked the description of read/write lock
Regarding testing "glue": static typing often gives evidence (but not proof) that code is glued together appropriately [refactoring even small projects without tests in Haskell is a joy: the compiler essentially tells you what to change]. However, it doesn't give evidence that the high level behaviour is what it needs to be. So I think higher level tests are still needed.
I think maybe changing the first question from...
> Am I confident the feature I wrote today works because of the tests and not because I loaded up the application?
to...
> Am I confident the feature I wrote today works because of the tests and type checking, and not because I loaded up the application?
will probably help you to answer the question about how much static types allow you to forgo tests. My instinct is that in most cases, high level tests are still worthwhile.
What I had in mind specifically in the answer, was the case of changing "interfaces" between parts of code. For example, the case of changing a function's arguments, or how it uses them, but omitting to change a call site. Checking that the call site just calls the function would not be enough to produce a failing test, especially without type safety. The test would actually need to assert on what the function does, e.g. its return value for a pure function.
Yes, I think trying to test against every single possible breaking change is not valuable.