Comments (2)
Yes, there is. createRegistry
is privileged, so it - and only it - can access the protected idCounter
variable. idCounter
is protected, because the whole layer tree management relies on the uniqueness of layer IDs. This uniqueness is only guaranteed until idCounter
is protected. After then, the idCounter
will be accessible (rewritable) from outside of the layer tree object, thus it can be compromised (it will be vulnerable).
This can be a real problem, when you aren't the only developer of your code, and one of your colleagues accidentally uses idCounter
in a non intended way, breaking the rest of the logic of the layer tree. In another scenario, you finish your code, return to it after a year or two, forget about the unprotected variable, and you use it in a non intended way. This can lead to a debug hell (especially if you don't have unit tests) taking several valuable days out of your hands.
from mastering_openlayers3.
Ok, I see that now. Other than wrapping a prototype.createRegistry
in a closure (which would probably be overkill), I haven't found a clean way to move it out of the constructor. It would be nice to have another implementation option here, but the way you did it seems to be the only truly secure way.
Thanks for the feedback.
from mastering_openlayers3.
Related Issues (14)
- Book Question HOT 2
- css button.active typo? HOT 1
- Uncaught TypeError: this.scrollTo is not a function HOT 7
- dynamic forms HOT 3
- Can't get WMS button work HOT 2
- API availability HOT 3
- ch04_thematic question HOT 4
- categorized colors are invalid (sometimes) HOT 1
- ch05_draw handleEvents question HOT 2
- ch05_measure question HOT 2
- ch03_fileapi question HOT 1
- How to draw geometry on preexisting layers? HOT 1
- styleGraduated missing typeof HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mastering_openlayers3.