Tuesday, 6 August 2013

Are Protected Auto-Caste Methods Ok?

Are Protected Auto-Caste Methods Ok?

I often have superclasses that contain a more abstracted form of a class
as a member variable than my subclasses need. I find my code littered
((ClassName)variableName).methodName(). Is the best way to solve this to
create a protected/private method called something like
getVariableNameAsClass()? It's not much shorter in letters, but an IDE can
do that much faster than maneuvering around with the keys to add in
parenthesis. Or is there a better solution?

No comments:

Post a Comment