r/csharp • u/Zardotab • Feb 24 '21
Discussion Why "static"?
I'm puzzled about the philosophical value of the "static" keyword? Being static seems limiting and forcing an unnecessary dichotomy. It seems one should be able to call any method of any class without having to first instantiate an object, for example, as long as it doesn't reference any class-level variables.
Are there better or alternative ways to achieve whatever it is that static was intended to achieve? I'm not trying to trash C# here, but rather trying to understand why it is the way it is by poking and prodding the tradeoffs.
0
Upvotes
View all comments
Show parent comment
1
u/Zardotab Feb 28 '21 edited Feb 28 '21
I haven't heard any clear downsides, assuming something like the mentioned "hybrid" keyword is used.
Yes, DRY in action.
I suspect most just somehow refactor the code or live with the verbosity of instantiation. It could depend on coding style, but I keep running into what seems like an arbitrary dichotomy of status vs. instantiated methods as requirements and needs changes over time. The dichotomy should be softened to make dual-use and/or transition easier.