6

Maybe I'm overthinking about naming, but it's a problem I've encountered several times and it was really annoying every time.

I have three interfaces. The first is IAssembler, which has assemble(...) method. The second is IDisassembler with disassemble(...) method, and the third is [no good name for that one] which inherit from them both. How would you call the last one?

More examples: serializer and diserializer, compiler and decompiler, encrypter and decrypter...

The conventions might change a bit between languages - I mostly use c++/c#.

9
  • 4
    Maybe not an answer in and of itself, but very much on point: a codec (e.g. video codec) is named from it being used for coding / decoding. A modem (such as your old 56k modem) is named from it being a device for modulation / demodulation. Those (once) neologisms were created specifically because there was no good name for them otherwise. If you'd apply the same naming logic in your case, it'd be assembling / disassembling => asdis (For your other examples: sedes, comdecom (because codec is taken), endec). Who knows, maybe these will catch on ;)
    – Flater
    Jul 15, 2022 at 10:24
  • Came here to say just this! Jul 15, 2022 at 10:33
  • 2
    Since you mention c#, .Net has JsonSerializer which performs both serialization and deserialization. This isn't 100% intuitive, but in a world with good documentation, good method names, and intellisense, it's not a big challenge. While it makes sense to have a class that can perform an operation and its inverse, I'd hope that the multiple responsibilities of the class were well-divided internally.
    – Tim M.
    Jul 15, 2022 at 18:52
  • 2
    @Flater The most popular Rust serialization library is called serde, using the same naming scheme. (serialize and deserialize) Jul 15, 2022 at 19:07
  • 1
    It may be worth thinking about why you need a separate interface - in what contexts is it necessary to have an object that supports both assembling and disassembling? That may help you craft a descriptive name for the task that the interface will perform.
    – nneonneo
    Jul 15, 2022 at 19:12

2 Answers 2

14

Unless it actually reaches a point where for some reason you are using the term every other line, call it IAssemblerDisassembler. Clarity is more important than brevity.

2
  • 8
    Note that the impact of a name is not only in code, it also impacts verbal and written technical communication (whether informal, analysis, or documentation). I don't disagree with the answer itself, but "using it every other line" is not the sole impact that the chosen name has.
    – Flater
    Jul 15, 2022 at 11:40
  • @Flater Lines certainly exist in written technical communication as well :) but point taken, it's not meant to be taken literally. Jul 15, 2022 at 11:46
9

Very much on point:

  • A codec (e.g. video codec) is named from it being used for coding / decoding.
  • A modem (such as your old 56k modem) is named from it being a device for modulation / demodulation.

Those names, which were neologisms at the time, were created specifically because there was no good name for them otherwise.

If you'd apply the same naming logic in your case, it'd be:

  • Assembling / disassembling => asdis
  • Serialization / deserialization => sedes
  • Compilation / decompilation => comdecom (because codec is already taken)
  • Encryption / decryption => endec

When no commonly understood name is readily available, it is perfectly fine to create one for yourself (which is exactly what they did for codecs and modems). The only thing you should take care of is to define these neologisms in your dictionary.

I generally advise any codebase to already maintain such a dictionary, so that you can maintain a ubiquitous language between the various stakeholders involved in the project.
Starting from that good practice, the only requirement that flows from creating your own word is to add it to said dictionary.


Also, just for the sake of clarity, you don't have to form the new word from the initial letters of its constituent parts; but it is a helpful mnemonic that enables people to remember these new words.

You could instead call these four examples a Schmoopsie, Floopsie, Doopsie and Clyde; but that seems like a more confusing name and is therefore not as good.

Deciding on the clearest name is very contextual and can't be put into a singular rule. You have to consider the practicality of using it. Often, these kinds of names tend to form organically during the project's lifetime, as people have to consistently refer to [thing] and slowly start forming a ubiquitously agreed upon name that describes [thing].

This is how most words were formed in human history: long term conversational consensus.

7
  • 3
    Also, transceiver. Jul 15, 2022 at 19:00
  • 4
    A popular Rust package is called serde from SERialization/DEserialization. Almost exactly like your example!
    – nneonneo
    Jul 15, 2022 at 19:07
  • @nneonneo Great minds, huh? I just made the same comment on the main post within a minute of your comment. Jul 15, 2022 at 19:08
  • @nneonneo Although the proper analogy would be sedes.
    – A. R.
    Jul 15, 2022 at 19:54
  • 2
    A hardware block that does serialization and deserialization is a serdes. So yes, very close real-industry examples. Jul 15, 2022 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.