So, i didn't want to go too crazy with the title: This isn't about C# / Java, exclusively. I'm sure there are at least some other languages that effectively handle this in the same way. However, C# / Java are the only languages I'm currently working with, and I didn't especially want to start downloading other compilers / libraries just to see how widespread this is.
Also, here is what I'm doing, not why. I'll be happy to answer curiousity, but not before it's expressed =P
The issue?
In any given subclass, IF I don't personally include a call in its constructor to its superclass' constructor, the language makes the call automatically.
My question / issue
Is this necessary?
Before any of these classes are even available for my use, the class loaders will have run. All methods will have been placed in their respective look-up tables. Static constructors, if present, will run. Any declarations of class / instance attributes that happen to be paired with initialization calls will be done.
So... in the example of instantiating a subclass.
Suppose the superclass has no attributes that need initialized. Repeat: the superclass constructor does not have a single line in it.
What, then, is the purpose of forcing a call either manually or otherwise to this constructor?
Note: if only the languages hadn't seen fit to FORCE this call, I could easily answer this question for myself.
So far as I'm aware, anyway.. the subclass already has access to all the methods of its superclass. They can be referenced internally as well as externally through representation.
In this example, I see no reason to mandate a call to the superclass' constructor.
Anyone?
1) Bottom line, why force this? Even if it is necessary, was making it virtually impossible for me to conclusively test this important enough to save me from typing 7-8 characters? Seriously, if typing that little is "the problem"--you're the problem.
2) IS this necessary? Why?
And really, I do have a pretty good reason for wanting to do this. =P
(that is, for wanting to have the mandated call to the superclass eliminated)
Edit:
Succinctly, the only visible thing I am able to observe a (super class) constructor doing is initializing variables. What, if any, other things are they doing that the languages are hiding from view?
(Edited by Whuppee at 3:41 am on May 31, 2006)
-------
Unbelievably awesomesauce to the absurd degree that I wet myself.
Who else has created a LW/magnets
so explicit the mods deleted a screencap of it? =P