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

Eric Seidel eric at webkit.org
Tue Jun 1 22:09:20 PDT 2010


Let me summarize to see if I understand what should be updated in the
style guide/check-webkit-style:

Class static member variables should have an s_ prefix.
Protected and public member variables should be disallowed.
Private member variables should have an m_ prefix.
Struct member variables should have no prefix.

Did I understand correctly?


What about global statics?  Currently I believe most have no prefix.
Some have "k" or "g".

-eric

On Tue, May 25, 2010 at 9:44 AM, Darin Adler <darin at apple.com> wrote:
> On May 25, 2010, at 3:05 AM, TAMURA, Kent wrote:
>
>>> 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.
>>
>> As for protected data members, many classes use "m_" prefix. I found protected members without "m_" in HTMLTableCellElement and HTMLTableColElement. I guess they are legacy code and we should use "m_" for protected members too.
>
> Older classes did not use the "m_" prefix consistently. Public and protected members were a little slower to get changed than others because they affected more source files. We want to use "m_" for all non-static data members, but data members should also be private.
>
> Generally speaking, protected data members should be avoided entirely. Existing protected data members should generally be replaced with private data members and we can add protected accessor functions as needed.
>
>    -- Darin
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>


More information about the webkit-dev mailing list