How do most programmers prefer libraries handle known naming conflicts with other common libraries/namespaces?
For example, if I write my own “Stack<T>” data structure, and I know there is a naming conflict with the commonly used “System.Collections.Generic” namespace… What would most programmers prefer?
- Rename the type to avoid the name conflict. Perhaps something like “FirstInLastOut<T>” instead
- Keep the name conflict and make users handle it with alias or other means
The rename solution (#1) is kinda bad because it obscures the code. People know what a “Stack<T>” is but not a “FirstInLastOut<T>”. The #2 solution can make the library annoying to deal with if you run into name conflicts. Yes type alias exist, but you have to have a different alias for every type, so if you have “List<int>” and “List<string>” then that alone requires two alias as far as I’m aware.
Why am I asking? I have an open source library I’m working on here: https://github.com/ZacharyPatten/Towel This library has multiple data structures including List, Stack, AVL Tree, Red-Black Tree, Heap, Omnitree (an ND SPT), etc. So there is some cross over with System.Collections.Generic, but plenty of non cross over too.
I’m not gonna claim my re-implementations of the System.Collection.Generic data structures are better (I haven’t had time to optimize them), but I still want to keep most of them so I that have versions that follow my inheritance structure and follow my patterns.
Personally, I’m leaning towards using standard names like “Stack<T>” instead of “FirstInLastOut<T>” and just making people handle the conflicts however they want to, but I still want to hear some other peoples’ opinions, especially because System.Collections.Generic is such a fundamental/common namespace.
Maybe someday they will add alias with generics…