3 ms·
The article lay the testability issue, but offers no alternative... Since as far as i know there are none. Also article is kinda crap as it fails to understand
by gcb0 13y ago
The article lay the testability issue, but offers no alternative... Since as far as i know there are none.
Also article is kinda crap as it fails to understand the reason they are truly necessary. But upvoting to generate discussion here.
- philjackson 13y agoThe reason what are truly necessary? Private methods? The author doesn't seem to think they're worth bothering with given the trade-offs. Out of interest what makes you think they're necessary?
- ianstallings 13y agoThe reason they are used is to specifically hide implementation details from a consuming class or chunk of code. The reason we do that is so the caller cannot make assumptions based on internal details so in the future we can modify it radically and not impact the caller. This is abstraction and it's OOP 101.
- gcb0 13y agoThere are several systems that must run untrusted code. Such as advertisement. We actually depend on real private methods. just because what you do every day makes it useless, it's presumptuous to assume it's the same for everyone.
- philjackson 13y agojust because what you do every day makes it useless, it's presumptuous to assume it's the same for everyone. Exactly why I asked...
- gcb0 13y agofair. But it is still presumptuous to write an article about the subject and not even consider someone else has a use for it.
- esailija 13y agoYour code on the client side is merely a convenience for malicious advertisement code if accessible. How your client side code interacts with the server is what matters and the malicious code can do whatever your code can do with same privileges if you are including it on your page. If you are running untrusted code in JS then real private methods have only given you a very false sense of security. You should have run it in a sandboxed process instead.
- paultannenbaum 13y agoHere is a link to an article that discusses one possible way to test private functions: http://philipwalton.com/articles/how-to-unit-test-private-functions-in-javascript/ http://philipwalton.com/articles/how-to-unit-test-private-fu... He basically exposes them while in a dev environment, and then uses a build tool to make them actually private. I agree with weego's comment though, its something that isn't usually worth the tradeoffs, as long as your team has discipline.