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
0
u/Zardotab Feb 24 '21 edited Feb 24 '21
Often one can't know the future, at least in the domains I work with. I still would like a more explicit/specific use-case. I'm not understanding the kind of situations are you envisioning in which one can be that certain about the future.
I find a lot of programmers & designers over-estimate their ability to predict the future. If they were that good, they'd be golfing with Warren Buffett now, not slugging out code in a sweaty cubicle.
Sometimes I have API's that have methods that can (potentially) be used in isolation. It would be nice to use them in isolation when needed without the added clutter of instantiation. The forced static/non-static dichotomy is false or limiting.