4 ms·
This seems like a shortcut to type less at the cost of very leaky encapsulation, which I don't think is a good trade. You may or may not want to expose all of j
by vore 3y ago
This seems like a shortcut to type less at the cost of very leaky encapsulation, which I don't think is a good trade. You may or may not want to expose all of jnettool.tools.elements.NetworkElement as a new interface, but choosing inheritance will always force you to expose everything from the inherited class. Furthermore, if you're extending classes that were not explicitly designed to be extended, this is fragile as there is no contract between your subclass and the base class and an implementation change in the base class may break you in unexpected ways.
What I also don't understand is how you're supposed to instantiate the new NetworkElement from an existing jnettool.tools.elements.NetworkElement. With delegation it's easy (just construct a wrapper with the object to be wrapped), but if the library is giving you instances of jnettool.tools.elements.NetworkElement, how do you get instances of your own subclass instead?