Model: abstract or interface? [message #1745823] |
Mon, 17 October 2016 20:04  |
Eclipse User |
|
|
|
Hello,
I have a modelling question. I have read the thread [1] and have had a look into the EMF Book, but I still can not get it clear, when I should model a class as abstract and when as an interface.
In my model, I would like to use abstract/interface classes for mother nodes that contain attributes (no methods/operations yet, but maybe they might have them in future). Other child are inheriting from these mother nodes.
In context of EMF I don't see multiply inheritage an issue with abstract classes (as if working with plain Java). Or am I wrong?
So to sum it up my question is: When and why should I decide to model a class, of which I do not want that any instance to be created, as an interface and when as an abstract class?
Hope you can help.
Cheers
Emil
[1] https://www.eclipse.org/forums/index.php/t/128666/
|
|
|
|
|
Re: Model: abstract or interface? [message #1745898 is a reply to message #1745845] |
Wed, 19 October 2016 01:56  |
Eclipse User |
|
|
|
With with regard to 1., not all your classes are abstract so certainly not all your classes should be interfaces, multiple inheritance is not such a common pattern, and even when using multiple inheritance, you'll still generally want to reuse base class implementations as much as possible.
With regard to 2., you have a tool, you can write examples and see what they generate. I'm not here simple to describe hypothetical things that you might not be using in practice. You can answer such questions yourself. I suggest you create the classic diamond inheritance with A, B -> A, C -> A, D -> B, C and see how that's actually implemented by generated code.
|
|
|
Powered by
FUDForum. Page generated in 0.24489 seconds