HNHacker News
TopNewBestAskShowJobs

michalc

816 karma · joined April 7, 2016

https://charemza.name/
submissionscomments
michalc··on Show HN: Django/gevent view to download PostgreSQL table as CSV in single query
Hi, author here.

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.

michalc··on Technical Debt Is Like Tetris
I like the analogy, but it slightly suggests that you're always powerless along the way and that the debt is inevitable. I think there _is_ a technique that is possible in a lot of situations: not putting in abstractions/complexity that don't really do any of transformation/transfer required of the underlying requirements.

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)

michalc··on The Worst Interface Ever: The Self-Destruct Switch (2004)
There could be something else at play in the call... they could have been scared that if a representative of Lexus admitted there was a problem with the design, they would be admitting liability.
michalc··on Fifolock: Synchronisation primitives for asyncio Python
Hello, author here.

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

michalc··on User Interfaces: How Not to Design a Microwave
Good post: although maybe missing a bit on testing? If the manufacturers got a just few people to try to heat up some bolognese, they would probably soon have discovered their UI needs a of tweaking.
michalc··on Questions to ask yourself when writing tests
Thinking about this, at the moment, I don't think static typing is a replacement for testing (or vice versa!). Although, apparently, with something like LiquidHaskell, you can get more logic "into" the types and checked by the compiler, but I'm unsure how much you can do when it comes to more complex business logic.

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.

michalc··on Questions to ask yourself when writing tests
I would be interested in reading it... if / when, if you can send me a link, that would be great!
michalc··on Questions to ask yourself when writing tests
Perhaps this part is not clear / well defined, but roughly, I meant that code coverage is (about) 100% for the lines added/changed, and some "reasonable" subset of possible breaking changes would be picked up by failing tests.

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.

← PreviousPage 4 of 4