[OpenLayers-Dev] Re: [OpenLayers 3] type instantiation performance

Eric Lemoine eric.lemoine at camptocamp.com
Sun Oct 17 12:36:25 EDT 2010


On Sunday, October 17, 2010, Peter Robins <openlayers at peterrobins.co.uk> wrote:
> On 17 October 2010 12:24, Eric Lemoine <eric.lemoine at camptocamp.com> wrote:
>> To illustrate again how things would look like with what I'm
>> proposing, here's an example involving OL.Layer and OL.Layer.Vector,
>> assuming the latter inherits from the former:
>>
>> OL.Layer = function(options) {
>>    // constructor
>>    ...
>> };
>> OL.Layer.prototype = {
>>    // prototype
>>    ...
>> }
>> OL.Layer.Vector = function(options) {
>>     OL.Layer.call(this, options);
>>     ...
>> };
>> OL.inherit(OL.Layer.Vector, OL.Vector, {
>>     // prototype
>>     ...
>> });
>
> um, shouldn't that read:
>  OL.inherit(OL.Layer.Vector, OL.Layer, {

Yes, sorry about that.

>
> ok, so the first 2 statements would be in the OL.Layer file, and the
> 2nd 2 in OL.Layer.Vector
>
>> I don't think this is such a major change. It would basically just
>> involve changing a few lines in all the files including class
>> definitions. But maybe you see this as a major change for other
>> aspects?
>
> no, actually, thinking about it some more, I don't think it would be a
> major change, as the user/programmer would continue to write:
>
> myLayer = new OL.Layer.Vector();

Yes, no API change for instantiation.


>
> and wouldn't need to bother how inheritance is handled internally
>
>> As Andreas said, we could also address the overhead issue by using
>> object litterals
>
> yes, agreed. Projection is another example.

Though object litterals for projection objects doesn't sound like a
good match to me.

Cheers,

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com


More information about the Dev mailing list