On 20/11/2017 13:22, Nicolas B. Pierron wrote:
On 11/20/2017 10:01 AM, Mark Banner wrote:
Now that we don't have legacy add-ons outside of our control, I would like to propose that we stop using Object.freeze/Object.seal on most of our objects.

I would personally recommend to every JavaScript developer that they should use these functions, in web pages, in JavaScript libraries, …

I believe that Object.freeze and Object.seal are sanity functions, part of defensive programming, used to guarantee that no other part of the code is doing something which is not intended.
I can understand the idea here, but I'm failing to believe that doing this would outweigh the benefits of having a unit test system where I can truly test at the unit level (or, more easily test at the integration/functional level).

If we had a complex function bar(), which, as part of it called Object.foo, how could I ensure that Object.foo is called with the correct parameters according to the inputs of bar()?

If Object is frozen, then I can't change Object, which means I either have to have some sort of abstraction interface, or a backdoor into Object, both of which would add extra overhead and complexity which doesn't seem to be the ideal.

Are there alternative ways we could achieve the same without the (or with low) complexity/overhead?

Mark.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to