[webkit-dev] Style question: static, protected, or public members

Darin Adler darin at apple.com
Mon May 24 16:19:21 PDT 2010


On May 20, 2010, at 8:54 PM, TAMURA, Kent wrote:

> What's the naming rule for non-const static members?
> 
> Some classes give "s_" prefixes:
> WebCore/page/DOMTimer.h:        static double s_minTimerInterval;
> WebCore/page/GeolocationPositionCache.h:    static int s_instances;
> 
> FrameView gives "s" prefix:
> WebCore/page/FrameView.h:    static double sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache
> 
> Settings gives "g" prefix:
> WebCore/page/Settings.h:        static bool gShouldPaintNativeControls;
> WebCore/page/Settings.h:        static bool gShouldUseHighResolutionTimers;

If we have to use a prefix for this, I suggest the "s_" prefix.

> And what about public and protected members?  The style guide has no exceptions for them, so I think they should have m_.  But many classes in WebCore don't use m_ for public members.

Generally speaking I suggest we do not use the "m_" prefix for the members of structs. And I suggest that classes with public data members be structs instead of classes. Classes that have public data members only for historical reasons should be changed so the data members are not public. We should talk some specific examples.

    -- Darin



More information about the webkit-dev mailing list