Static vs instanced class
Duplicate
Please forgive me if this question seems trivial - I am looking at some source code that otherwise looks good, but it raised some questions ...
If a given class has no data members, that is, it does not maintain any state, is there any advantage to not labeling this class as a static class with static methods?
Are there any benefits to unlabelled methods that don't store state as static?
Thanks!
EDIT: Since someone brought up this, the code I'm looking for is written in C #.
a source to share
If a class doesn't maintain any state, doesn't have any instance methods, and can be fully implemented using the class's methods, I usually take a long time to see if its behavior would actually be more useful elsewhere. I believe they usually have many methods on strings doSomethingWithItem(Item item)
, which would make more sense as an instance method in Item
.
Yes, I know this does not answer your question, but I think others have already understood this well and I wanted to get another perspective.
a source to share