Hi Loic,
I'm starting a project with Google Map, and for our necessities I'm
thinking about implementing a API that wraps Google Map API. I'm not
sure about extending Google Map classes because I'm afraid that if I
implement a method, let's call it methodA, and later on Google decides
to implement methodA, I'd be overriding this one...
would be it be safe extend Google Map classes ? In my opinion this type
of APIs should be wrapped, what do you reckon ?
Thanks
On 17/02/11 13:19, Loic Giraudel wrote:
I think it's a question of understanding your object architecture.
A Car Object is a Vehicle Object so Car should extend Vehicle (extending).
But if Car contains a Vehicle (wrapping), what does it mean ?
Your code will be harder to understand if your architecture is
performance-oriented and not logic-oriented...
Regards.
On Thu, Feb 17, 2011 at 13:27, Fran <[email protected]
<mailto:[email protected]>> wrote:
Hi guys,
I sometimes run into this doubt when I have to use someone else
classes or API. Let's see this example:
/* API or Class: */
var SomeOneElseClass = function (args) {/*...*/};
SomeOneElseClass.prototype = {
doSomething : function () {/*...*/},
doSomethingElse : function () {/*...*/}
}
/**************************************/
/* Wrapping: */
var MyClass = function (args) {
this.__someOneElseClass = new SomeOneElseClass(args);
// ...
};
MyClass.prototype.doEverything = function () {
this.__someOneElseClass.doSomething();
this.__someOneElseClass.doSomethingElse();
}
/**************************************/
/* Extending: */
var MyClass = extend(SomeOneElseClass, {
constructor : function (args) {
MyClass.superclass.constructor.apply(this, args);
// ...
},
doEverything : function () {
this.doSomething();
this.doSomethingElse();
}
});
/**************************************/
Could anyone tell me pros and cons of using one or the other ?
Thanks.
--
To view archived discussions from the original JSMentors Mailman
list: http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]
<mailto:jsmentors%[email protected]>
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]