in reply to Conditional inheritance strategy
Hm. It's not possible to tell from the posted snippets whether this really makes sense.
My instinct tells me that the XML or JSON is only used to initialise the objects of class My, and that once so initialised, the instances from either source are essentially identical. If so, then I would deem what you are doing as "unnecessary inheritance".
Based upon the above assumption, I would suggest that by using inheritance here, you are loading--and persisting--the overheads of the XML or JSON classes into each instance of My class for no good reason. That is, you are forcing each instance of My class to carry around the baggage--instance data and class references--of whichever base class was used to initialise it. And for no good reason, as that baggage will never be used again during the life of the My class instance.
If so, if you instantiated an instance of the relevant XML or JSON class to just parse the source data; then retrieved the data required by My class; and then allowed the parse instance to be reclaimed as soon as the initialisation of a new My class instance was complete; then your My class instances might be individually smaller. And possibly more efficien,t because of shorter method resolution paths.
Hard to tell from what you've posted, but worth considering.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Conditional inheritance strategy
by citromatik (Curate) on Oct 27, 2010 at 15:06 UTC | |
by BrowserUk (Patriarch) on Oct 27, 2010 at 15:13 UTC | |
by citromatik (Curate) on Oct 27, 2010 at 15:46 UTC | |
by BrowserUk (Patriarch) on Oct 28, 2010 at 09:09 UTC | |
Re^2: Conditional inheritance strategy
by JavaFan (Canon) on Oct 27, 2010 at 14:31 UTC | |
by BrowserUk (Patriarch) on Oct 27, 2010 at 14:52 UTC | |
by JavaFan (Canon) on Oct 27, 2010 at 16:27 UTC |