0

I am currently refactoring a project where I come across the following kind of code multiple times:

propertyFunction: function (feature) {
  doSomethingOnyWithFeature(feature);
  ...
}

Methods, that make use only of its only parameter and not of any context could well be defined as a method of the parameter itself - or, preferably, its prototype.

The issue is, that in my case, "feature" is very often from a foreign library (in my case OpenLayers) which itself is used in other parts of the project where an extended prototype is not something we want.

So, what I want to achieve is: Adding method logic to each of the elements having the respective prototype. Besides extending of the prototype I am thinking of building a Wrapper - but when do I wrap the features?.

Any ideas?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.