3 ms·
Rather than ``sortRectsByArea`` I'd rather have a generic ``sort`` that supports a Schwartzian transform, like Python's ``sorted(stuff, key=transform)``. Funct
by xapata 10y ago
Rather than ``sortRectsByArea`` I'd rather have a generic ``sort`` that supports a Schwartzian transform, like Python's ``sorted(stuff, key=transform)``.
Function or method names that postfix the mode onto the verb, like "parse_from_file", are usually an indication that the design could be improved by creating a consistent interface for the various modes. Sometimes it's better to provide a handful of modes, but I always double-check when I see myself writing names like that.
[0] https://en.wikipedia.org/wiki/Schwartzian_transform https://en.wikipedia.org/wiki/Schwartzian_transform
[1] https://docs.python.org/3/library/functions.html#sorted https://docs.python.org/3/library/functions.html#sorted
- marcosdumay 10y agoThat depends a lot on your actual architecture and domain. Some times, you need parse_from_file, and nothing else. Other times it's worth parametrizing everything and just assembly generic code at the top level.