Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I read the article that @nemesv referenced me to (Thanks :)) and I thinks there is one more disadvantage that was not mentioned, so I thought I'd add it here for reference. Here is a quote from the article:</p> <blockquote> <p>Disadvantages</p> <p>A disadvantage of this pattern is that if a private function refers to a public function, that public function can't be overridden if a patch is necessary. This is because the private function will continue to refer to the private implementation and the pattern doesn't apply to public members, only to functions.</p> <p>Public object members which refer to private variables are also subject to the no-patch rule notes above.</p> <p>As a result of this, modules created with the Revealing Module pattern may be more fragile than those created with the original Module pattern, so care should be taken during usage.</p> </blockquote> <p>And my addition:</p> <p><strong>You can't use inheritance with this pattern</strong>. For example:</p> <pre><code>var Obj = function(){ //do some constructor stuff } var InheritingObj = function(){ //do some constructor stuff } InheritingObj.prototype = new Obj(); InheritingObj.prototype.constructor = InheritingObj; </code></pre> <p>This a simple example for inheritance in js, but when using the <a href="http://blog.pluralsight.com/2012/10/09/revealing-prototype-pattern-structuring-javascript-code-part-iv/" rel="nofollow">Revealing Prototype Pattern</a> you'll need to do this:</p> <pre><code>InheritingObj.prototype = (function(){ //some prototype stuff here }()); </code></pre> <p>which will override you inheritance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload