protected generic type aliases in classes #4816
Unanswered
Gallimathias
asked this question in
Language Ideas
Replies: 1 comment
-
related to #218 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
If you have an architecture that uses a handful of generics, you quickly come to the point that their use quickly becomes confusing and incomprehensible, especially due to long class names.
Generally, there is already the possibility to use aliases for types, but not for generics, and not even within a type.
As an example I have a static type of a TestFramework
The static class
If I now want to use this type within a class, it quickly becomes messy.
There are two simpler options.
Possibility A, declare the alias directly with the corresponding types.
Option B, write a base class that can pass the generics directly to the alias. Since the aliases would be protected and visible, all inheriting classes could use the alias.
Especially in the example shown here, generalisation can make the problem much worse by adding at least one more external input and output pair. The aliases make the readability much easier.
Beta Was this translation helpful? Give feedback.
All reactions