Static functions
Tim Jansen
tim at tjansen.de
Mon Jan 12 19:42:55 GMT 2004
On Monday 12 January 2004 19:47, Christian Loose wrote:
> Some believe that it's not only good for optimization:
> http://www.cuj.com/documents/s=8042/cuj0002meyers/
I think I see Meyer's point, but I see it from a different perspective:
classes do not only keep methods and their data together, they also
categorize methods. This is important for two things:
- reading source: when a class function is invoked I know where to find it.
But everytime I see a non-class function that i don't know yet, I need to
grep through the sources to find it, because it is not obvious where to find
its code. To fix it people sometimes use prefixes that can help you to find
the right header, but this also decreases readability and forces you to
invent new naming conventions (and as optimization was the original topic:
long function prefixes also hurt linking performance when gcc on Linux is
used)
- in public APIs: when I search for a feature in a large library I search for
classes and then look at their methods. But when there are also class-less
functions that could offer the feature I look for, I either need to look at
two places (the class list and the function list) or the overview needs
another level in the hierarchy to group closely related classes and
functions. Both make it much more difficult to find a feature
bye..
More information about the kde-core-devel
mailing list