question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why doesn't MatterJS make more use of the prototype pattern?

See original GitHub issue

Plop,

We use the MatterJS objects as follow:

var myEngine = Matter.Engine.create(...);
Matter.Engine.run(myEngine);

I personally love the prototype pattern, which would allow to write myEngine.run() instead of going through Matter.Engine again. Why doesn’t MatterJS use it? I’m just curious about it.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Araluncommented, Apr 15, 2015

15 days later, and after reading a good dozen of articles, I still don’t understand why MatterJS is using this kind of code rather than using the Prototype chain. In my own limited vision of it, it’s just inducing more code to write and not using one of JS most powerful feature. The articles that @marlonicus provided rather speak for the prototype pattern, not for the namespace use.

If this is not the right place to discuss it, please accept my apologies and close as resolved.

1reaction
Araluncommented, Mar 31, 2015

Well THANK YOU, I wanted to be productive today. GUESS NOT.

Thanks for the links. To me, it kinda seems like a pointless excess of code, so I’m definitely missing something. Coming back here tonight when I have read all that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript prototype subtleties: why 'new' matters
The second pattern was designed to make prototypal inheritance look like classical inheritance. It's only used in JavaScript and it hides the way...
Read more >
Prototype Pattern in TypeScript - Medium
The Prototype design pattern is good for when creating new objects requires more resources than you want to use or have available.
Read more >
Prototype Design Pattern in JavaScript | DigitalOcean
The prototype model is used mainly for creating objects in performance-intensive situations. The objects created are clones (shallow clones) of ...
Read more >
Why did JavaScript creators decide to use the prototype ...
The gang of four book clearly mentions that prototype pattern shines best in ... point where you can make a bunch of snap...
Read more >
Landslide size matters: A new data-driven, spatial prototype
Many more applications should be successfully validated before considering ... However, no data of landslide dynamics (e.g., kinetic energy) are currently ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found