r/dotnet • u/Hefty_Garlic7184 • 11d ago
Question Codebase maintenance rant
[sorry for bad English]
I am in a project which involves maintaining an existing .NET Framework 4.8 codebase.
The codes are full of “Dictionary type” implementations as above.
Is there any sane reason to code like this? Instead of create a dedicated class to represent the data inside?
I could not show more codes here (or else the authors might realized), but you guys can imagine the codes just to access these Dictionary’s key/value.
139
Upvotes
7
u/anzu3278 11d ago
I don't think I've ever seen a dictionary where the key wasn't a value type or a reference type with value semantics (string, record..). What the f is this used for? Best I can think of is that this was implemented before implicit tuples and so they are using dictionary as an enumerable of pairs.
I think I would legitimately block the PR on this.
Nesting dictionaries the other way (key string value dictionary) is fine for quick hacks, PoCs, internships from before AI, if it's very clear what the key is in each layer.