1. 9

What made you go ‘yay, I love working with this object!’, and what made you go ‘ugh, why is it like this’?

Some rules:

  • You have to link to the docs of the interfaces you name
  • Spend a sentence or two on your experiences and/or feelings in working with this interface, and how they flow from the interface’s design.
  • Extra bonus points for also replying to other people’s posts, ands sharing your experiences with the interfaces they named.
  • No quibbling about what counts as OO.
  • Focus on the interfaces, not the programming languages.
  1.  

  2. 4

    I’m not very fond of the Scikit-learn Estimator interface (link to Getting Started docs because the API docs for the interface are scattered across a bunch of mixins). I dislike the fact that my_model.fit() modifies & returns self, rather than creating & returning a new, fitted, model. Or perhaps I dislike the fact that the concept ‘model definition’ & ‘fitted model instance’ are jammed into one class, distinguished only because the latter have attributes that end in a single underscore (E.g. coef_, or n_classes_, or whatever things that particular model family estimates when fitted.)

    I do love the Python pathlib API. It really gets that a Path represents a place in the filesystem; that we want a Path interface firstly because safely constructing&manipulating paths is hard, but equally because we want to know what is near that place in the filesystem.

    1. 4

      I’m not too thrilled with the inconsistencies of Array objects in JavaScript, in particular the mixing of methods that mutate and ones that don’t mutate the original array, and some weird choices for method signatures (e.g. concat() accepting either arrays or values) and return values (e.g. push() returning the new length of the array).

      Edit: As for the love part, I find working with the DOM pretty satisfying, as it tends to be rather verbose and unsurprising. As of late I seem to prefer the functions-and-plain-objects approach, and a good exponent of that is symbol-tree, which is DOM-style manipulation for arbitrary tree structures.

      1. 4

        I quite enjoy writing SQL queries in Java/Kotlin with jOOQ. It turns SQL into a strongly-typed DSL that plays very nicely with idiomatic application code and turns many varieties of malformed SQL into compile-time errors instead of runtime ones. It is probably the most impressive use of generics I’ve ever come across.

        One thing I like about it is that when I try to do something new I’ve never had reason to do before, more often than not the first thing I think to try just works, no need to go fussing around trying to find some obscure incantation. (Admittedly, that’s after an initial learning curve.) To me that’s the sign of clean, intuitive API design. But when you need to do something crazy, it exposes all the hooks you need to get the job done.

        1. 2

          Going with Ruby for this, since it’s the most-OO language that I’m familiar with.

          Like: the Ruby Pathname class. It’s just syntactically so much nicer to path_a.join(path_b) than to awkwardly write out File.join(path_a, path_b) every time. Ditto with pretty much any operation you want to perform on paths (e.g. convert relative to absolute). Treating paths as distinct objects just ends up feeling more ergonomic than treating them as raw strings or bytes. It also helps that none of the Pathname methods mutate state; they all return new Pathnames rather than modifying in place.

          Dislike: the File/FileUtils separation. It’s needlessly awkward; for example, you can create and delete files with File, but to move or copy a file you need to use FileUtils. There is duplicated functionality, e.g. chown existing in both. The split feels fairly meaningless and it’s annoying in practice.

          1. 3

            path_a / path_b is even nicer and is portable too.

            1. 2

              If we’re doing Ruby, to_enum is weird and wonderful and fantastic.

              Bends one’s mind a little before you grok it… but once you do…

            2. 1

              I once had to do some unnatural things with ELF files. I would have used libelf like everybody before me but I needed my program to work on Windows and Linux. I stumbled upon http://elfio.sourceforge.net

              What a joy to work with.