Quote for the day

I’m reading this and I liked this:

The obvious skill I learned was how to write tests using a fancy testing framework, but the meta-thing I learned which has been even more useful is the fact that writing a test-case generator and a checker is often much more productive than the manual test-case writing that passes for automated testing in most places.

Also good:

It’s not that these books aren’t useful, it’s that almost all of them are written to make sense without any particular background beyond what any random programmer might have, and you can only get so much out of reading your 50th book targeted at random programmers.

Service sadness

I read this and it made me sad. Exposing CRUD API makes me sad. CRUD is for databases, within transactions, not services. Services should have query (GET) and submit (POST) only. Oh, and calling a service an API makes me sad. Calling a URL or its path an “endpoint” makes me sad. An endpoint is a computer which processes a message, it’s not a URL path. The idea of “routing” makes me sad. Using plurals in URLs makes me sad. Exposing hierarchies unnecessarily in URLs makes me sad. Business process which doesn’t cater for optimistic concurrency controls makes me sad.

Arrays in PHP

Some notes about arrays in PHP over here: PHP: Frankenstein arrays. I was already aware of most of that but I thought the notes at the bottom about supporting JSON were handy:
If you want to enforce an array to encode to a JSON list (all array keys will be discarded), use:

json_encode(array_values($array));

And if you want to enforce an array to encode to a JSON object, use:

json_encode((object)$array);

Also array_is_list is available as of PHP 8.1.