But the OP is talking about static functions, not data. |
I referred to any static members. Static functions are nothing more than just global functions.
They don't behave like other OOP constructs: e.g. they are not inherited, they cannot be specified in an interface, their implementation cannot be easily substituted for testing. Essentially they are code operating on arguments and global data - this is structural programming, not OOP.
static variables do not necessarily make your project less object oriented. |
All right. Call it as you wish. They are a sign that your OO design is seriously flawed.
Anyway, there is nothing really that bad in using globals, if you know what you are doing, but you are programming structurally then.
Static members and attributes are also used for patterns such as singleton |
Singleton as usually used in C++ or Java is an anti-pattern, not a pattern. It is just a fancy-named global variable (stateful singleton) or global constant (stateless singleton). Funny they added static to C++, because it already had global variables/functions from C. But this makes the language feature list longer, and attract people that like dealling with complex things, so I suspect it was a good marketing move. They used a new name and a slightly modified syntax, so they could sell the old thing (globals) as the new thing (statics). And people bought it.
Now we have to maintain crappy applications riddled everywhere with static...
The scope of static class members is certainly not global!
|
So what is it? If there is exactly **one** something per the whole application, its scope is global.
http://corfield.org/blog/post.cfm/Static_is_Evil