<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: jonathan-snook</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/jonathan-snook.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2009-04-30T19:59:39+00:00</updated><author><name>Simon Willison</name></author><entry><title>Why I don't love JavaScript's Module Pattern</title><link href="https://simonwillison.net/2009/Apr/30/module/#atom-tag" rel="alternate"/><published>2009-04-30T19:59:39+00:00</published><updated>2009-04-30T19:59:39+00:00</updated><id>https://simonwillison.net/2009/Apr/30/module/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://snook.ca/archives/javascript/no-love-for-module-pattern"&gt;Why I don&amp;#x27;t love JavaScript&amp;#x27;s Module Pattern&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Jonathan Snook points out that the module pattern (where private functionality is hidden in a closure and only public methods are revealed to outside scopes) makes code a lot harder to debug. I use the module pattern for pretty much everything, not because I want to keep stuff private but more to avoid any chance of leaking out in to the global namespace. If I need to debug a value I temporarily assign it as a property on the global window object.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/closures"&gt;closures&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/debugging"&gt;debugging&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/javascript"&gt;javascript&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jonathan-snook"&gt;jonathan-snook&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/modulepattern"&gt;modulepattern&lt;/a&gt;&lt;/p&gt;



</summary><category term="closures"/><category term="debugging"/><category term="javascript"/><category term="jonathan-snook"/><category term="modulepattern"/></entry></feed>