now, clearly, his approach is idiotic.
now, many other tutorials, are idiotic that try to throw in “engineering methodologies”. Zakas's book is that like. His chapter on object has titles like these: factory pattern, constructor pattern, combination constructor/prototype pattern, dynamic prototype pattern, parasitic constructor pattern, durable constructor pattern, pattern ya mom.
Zakas book is not bad. Aside from the “patterns” approach, it's rather solid. It's always good to have different perspectives on a language. However, his “software engineering” approach is simply misleading. Here's a concrete example. Excerpt:
The constructor property was originally intended for use in identifying the object type. However, the instanceof operator is considered to be a safer way of determining type. Each of the objects in this example is considered to be both an instance of Object and an instance of Person, as indicated by using the instanceof operator like this:
His remark on
instanceof operator is technically incorrect. Because the
of course, he is aware of that, because later in the “Parasitic Constructor Pattern” section, he remarks:
A few important things to note about this pattern: there is no relationship between the returned object and the constructor or the constructor's prototype; the object exists just as if it were created outside of a constructor. Therefore, you cannot rely on the instanceof operator to indicate the object type. Because of these issues, this pattern should not be used when other patterns work.
the results of this “software engineering” approach is that it tries to force a language into a elusive “software engineering” perspective, resulting confusion. It's like trying to explain the solar system with earth-centric view. Instead of the simple model of planets revolving around the run, it tries to see them revolve around earth, resulting complicated paths of epicycles. 〔➤ Epicycloid and Hypocycloid〕