Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify difference between "extends" and "superclass" properties of types #21

Closed
felixlinker opened this issue Oct 4, 2017 · 5 comments

Comments

@felixlinker
Copy link
Contributor

In the documentation, there is only mentioned how to use the superClass property of a type. But the code and further examples relating to bpmn-js also show there is a extends property.

It would be great to know, how those differ as their naming is rather ambiguous.

@nikku
Copy link
Member

nikku commented Oct 4, 2017

extends is basically a mechanism to plug-in additional meta-data to known elements without modifying the existing inheritance hierarchy.

Think about it as a plug in mechanism from the side.

Instead of doing this:

A
^
|
B

You may provide additional type information to A by extending it with a type definition C:

A <-- C <extends>

This means A is now of type C, too and knows all properties of C.

As part of model checks you may now ask whether your dealing with C if you got an instance of A at hand: isA(a, C) === true.

Understandable?

@felixlinker
Copy link
Contributor Author

Understandable! But what exactly is the difference between extends and superClass now? As far as I understand, in both cases (B extends A/B has-superClass A) isA(b, A) would result into true wouldn't it?

@nikku
Copy link
Member

nikku commented Oct 4, 2017

That is correct. The difference is that extending is implicit while inheriting via superClass is explicit.

Take the example of constructing an instance of A: In the extends case constructing A will give you all the properties defined in C, too. In the superClass case, you'd need to instantiate B to get all the properties defined by it.

@nikku
Copy link
Member

nikku commented Oct 4, 2017

Feel free to ask more questions, if that helps you understand. I'll leave this issue open until we add the actual documentation for extends.

@nikku nikku closed this as completed in 1f015d9 Oct 4, 2017
@felixlinker
Copy link
Contributor Author

Ok, cool. Along with the new documentation I think I got it! Thanks for the quick response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants