On 21Jan2023 01:32, Thomas Passin <li...@tompassin.net> wrote:
In another thread ("Improvement to imports, what is a better way ?") there was a lot of talk about line length, PEP-8, etc. I realized that one subject did not really come up, yet it can greatly affect the things we were talking about.

I'm referring to the design of the functions, methods, and classes. When they are well designed, or more likely, refactored over and over again, they can lead to code that reads almost like pseudo-code. [...]

Yeah. Personally, I summarise this as the maxim: "ergonomics matter". Code should be easy to use and easy to read.

I've got a heap of code I've refactored after the initial implementation to make it easy to use, if only to make it easier for _me_ to use to do more things with it.

I've also got decorators and context managers and special classes all aimed at making all the things easier to use and easier to _write_ (because some decorators (a) provide flexibility for the caller - easier to use and (b) implement standard boilerplate logic for common types of parameters, making the function/method implementation easier to write.)

And increasingly I've got docstrings with _example_ code which doubles as a doctest. Making it easier to understand how to easily use this thing.

Cheers,
Cameron Simpson <c...@cskk.id.au>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to