[webkit-dev] Clients and the Page constructor
Steve Block
steveblock at google.com
Wed Jul 21 12:57:58 PDT 2010
> What exactly does not scalable mean? Passing arguments to the constructor rather than setting
> them up later is often good because there is no time window where the object is not set up.
> Generally speaking we don’t want to have to write code to handle a client of 0 unless it’s absolutely
> necessary.
Agreed. My motivation was to avoid the long, growing, list of
arguments and to avoid the need to update the call sites for all
platforms with an extra '0' each time a new optional feature is added.
> Another option, if the objection is a function with a lot of arguments, is to pass in a structure with
> all the client pointers to the constructor.
That sounds reasonable. A structure of the client pointers for all
optional features, with each entry defaulting to 0, would solve this
problem.
Another argument for the setter is that it makes it easier to inject a
mock for testing in response to a LayoutTestController method call, by
simply calling the setter again to replace the real client with a mock
client. Personally, however, I think that this is somewhat abusing the
idea of setting a client. If the real implementation needs to be
switched for a mock at runtime in DRT, this should probably be handled
by the client itself - so the same client is used throughout the
lifetime of the Page.
Steve
More information about the webkit-dev
mailing list