[OpenLayers-Dev] constructor signatures

Peter Robins openlayers at peterrobins.co.uk
Fri Jun 18 13:14:02 EDT 2010


On 18 June 2010 16:53,  <christopher.schmidt at nokia.com> wrote:
> I regularly use a WMS server with no 'layers' param. I know that this
> is a special case, but the layer does not technically require this
> parameter to work. (Your server might; the spec might even, but
> the parameters that are required depend on your server.)

a situation I've often found with WMS servers is that the (WMS) params
depend on the state of the map; having the layers param dependent on
zoomlevel is a common issue. In some cases, I'm even using different
servers depending on the zoomlevel. In this case, you can't specify
the WMS params in the constructor, but only in a custom moveTo or
whatever.

So to me the key point is not whether a particular property is
necessary for a particular method in the object to function, but
whether it has to be present in the constructor. I would guess that
the number of truly required params (i.e. the object can't be
constructed without it) is very small.

To me, the big advantage of OL (and JS) is it's very flexible, and
allows me to change more or less any property or method whenever
necessary. Requiring me to enter something in the constructor param
(WMS params in the case above) even if I don't know at that point what
it should be seems like unnecessary bureaucracy to me, and IMO it
would be better simply to document what happens if certain params are
or are not present.

Anyway, that fits in better with the name 'options' - by definition,
all options are optional :-)

FWIW, I favour the single object argument, though it's not something I
would man the barricades about.



More information about the Dev mailing list