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

Darin Adler darin at apple.com
Tue May 25 09:44:35 PDT 2010


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



More information about the webkit-dev mailing list