I have a Blog class that does exactly what you think it would…create an object and handle it. That part is nice and clean.
I am now in need of a function that will quickly return a number of all the blogs in my database (not necessarily related to the blog object). Therefore, I am thinking a static method would be a good choice.
My question is, where should I store this static method? Here are a few options I can think of:
-
store it as a static method in the Blog class (maybe smelly because it has nothing to do with the object that class creates?)
-
create a new class for blog static functions (seems excessive)
-
find a better way to go about this altogether (yes, but what?)
Presumably something is managing the multiple Blog objects you create? If not, there should be, and that’s where the method belongs – no need for it to be static.