parkm / oldbpm

A JavaScript game where you shoot at bubbles.
0 stars 1 forks source link

Inheritance #9

Closed parkm closed 10 years ago

parkm commented 10 years ago

If we're going to use prototype inheritance do we really need mixins? I'm thinking that we can just substitute those with objects inside. So if we have a mixin _foo we'd use it as

function MyObj() { this.foo = new _foo() }

This would remove any naming conflicts that mixins could bring. But i'm not sure if that would be a problem if we used them sparingly.

dgpt commented 10 years ago

Eh, I don't even know anymore lol. Using them as objects inside of a prototype kind of defeats the purpose, as it would just be a separate object inside of the main object, and not part of the main object.

Let's just ditch mixins and use Prototypes only. I'm starting to see that there is no real benefit to mixins vs. Prototypes. What do you think? There should really only be a few things that need inheritance, anyway. Do you know if there is a way to test an object to see what it has inherited from? I think there is a way, but I can't think of any at the moment. If not, we can just make a wrapper for inheriting.

parkm commented 10 years ago

Yeah I think just prototypes would be best. I'm thinking that there's not much inheritance needed in this project, most things will inherit from a base object though. So there's probably going to be 2 levels of inheritance max.

Does instanceof not work?

dgpt commented 10 years ago

Yeah, sounds good.

instanceof definitely works. I think there are some caveats to it, like everything in JavaScript, but it should be fine.

On Wed, Apr 30, 2014 at 5:57 PM, Parker Miller notifications@github.comwrote:

Yeah I think just prototypes would be best. I'm thinking that there's not much inheritance needed in this project, most things will inherit from a base object though. So there's probably going to be 2 levels of inheritance max.

Does instanceof not work?

— Reply to this email directly or view it on GitHubhttps://github.com/despondentdonkey/bpm/issues/9#issuecomment-41865878 .

dgpt commented 10 years ago

Gonna close this out; pretty sure we're in agreement.