| > Comments and out of code documentation both have the same problems : - Blindspots - Rot This has nothing to do with the usefulness of comments (which is what i'm promoting). And no comments by themselves aren't sufficient for a system to do things. However, code by itself isn't sufficient to express intent. Code in isolation only serves to express a past *interpretation* of intent (not necessarily error free). > In the end, the most complete and trustworthy source of truth for the code is the code itself. For implementation I would agree. But not for intent. Both versions of the code presented originally only give us the structure. The latter gives us some names. But neither gives us intent. > Another point to consider is that for the same intent the structure may need to change, to evolve. Proper typing can insulate the code from those changes. I think I can agree with this in some cases and not in others. Basically it boils down to if a new type is really warranted. My opinion is that new types are warranted if there is some functionality that is unique to that type. That's hard to say in this example because neither of the examples actually gave us intent or context. But if it's the case of we're only going to be doing "String" things and "Pair" things then I don't think it's warranted to invent new types to do the things the existing types already handle. It's extra abstraction and indirection. As another commenter pointed out as well, a nitpick about the single letter variable name. It's something done in both of the original examples. It's bad in both but it's glaringly obvious in the shorter example. But changing the names here also really doesn't help us with the intent of the code. A good comment/description would. |