T
Tookelso
Is there any reason to declare an object as its Parent or Grandparent
class, then instantiate it as the intended class?
Example:
Class Oven { blah }
Class Microwave extends Oven { blah }
main function
// Note here we declare it as an Oven, but instantiate as a
Microwave
Oven myMicrowave = new Microwave
This seems to have no useful purpose. Why not just declare everything
as an Object, then instantiate as its own object. This seems to
propogate un-necessary casting.
Opinions? This code is all over the place at my workplace, and is
confusing and aggravating.
class, then instantiate it as the intended class?
Example:
Class Oven { blah }
Class Microwave extends Oven { blah }
main function
// Note here we declare it as an Oven, but instantiate as a
Microwave
Oven myMicrowave = new Microwave
This seems to have no useful purpose. Why not just declare everything
as an Object, then instantiate as its own object. This seems to
propogate un-necessary casting.
Opinions? This code is all over the place at my workplace, and is
confusing and aggravating.