[webkit-dev] Do we have a style preference about const member functions?
mjs at apple.com
Mon May 30 23:32:35 PDT 2011
On May 30, 2011, at 4:19 PM, Geoffrey Garen wrote:
> Const member functions:
> Do use const member functions in classes that are independent data holders, to help distinguish between references that can modify the data and references that can't.
> Do not use const member functions in classes that participate in object graphs, since the distinction is weak. Do not use const member functions for DOM or render tree nodes.
While I agree as to the DOM or render tree, I'm not sure this statement is right in general. A linked list node or tree node could useful have const methods, which give only const pointers/references to other nodes. If there is a reason const references to DOM nodes or renew objects are not useful, it is not due to the object graph participation itself, in my opinion.
> On May 30, 2011, at 4:08 PM, Ryosuke Niwa wrote:
>> On Mon, May 30, 2011 at 4:02 PM, Geoffrey Garen <ggaren at apple.com> wrote:
>> Do not use const member functions in complex classes that do a lot more than hold one piece of data
>> I'm not sure if the complexity of a class or holding piece of data are useful criteria. Looking at DOM or render tree, it seems that we don't want to use const when an object constitutes (i.e. object's data members are essential in creating) a larger data structure such as a tree or a list.
>> - Ryosuke
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev