Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Stop modifying String.prototype, _.prototype, and google.maps.prototype #806

@wylieconlon

Description

@wylieconlon

Apologies if this is a duplicate, I searched through a fair number of open/closed issues and pull requests to find a similar issue.

I think modifying the prototype of objects that you don't own is a fundamentally wrong way to design a library. For example, what if I were to define my own String.prototype.contains method? Would your library stop working? Would my application break? It can't go both ways.

From what I can see of the history of this project (7b6adde), it seems like there was a recent change in prefix from ngGmap to uiGmap. I can see why a .ns() function on the string prototype was useful for that, but I'm sure that a find and replace would have taken the same effort.

In a more angular-specific case, I think this makes your library much harder to understand at first. I was looking at your documentation and I saw this line:

//'GoogleMapApiProvider'.ns() == 'uiGmapGoogleMapApiProvider'
.config(['GoogleMapApiProvider'.ns(), function (GoogleMapApi) {

Since there are multiple ways to annotate dependencies, and dependency annotation is optional, I think this is unnecessarily confusing. Instead, I would propose that the documentation should not use custom prototype functions, and look like this instead (matching the Angular documentation):

.config(function (uiGmapGoogleMapApiProvider) {

The same argument applies to your custom extension of lodash and google maps. Why not wrap their code with your library-specific code? Other applications don't need to be aware of those extensions.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions