Anything named - objects, variables, classes..


In computer programming, shadowing occurs when a variable declared within a certain scope (decision block, method or inner class) has the same name as a variable declared in an outer scope. This can lead to confusion, as it may be unclear which variable subsequent uses of the shadowed variable name refer to, which depends on the name resolution rules of the language.


Quality Example

"Not using the same named is a more common practice to avoid confusion and shadowing"

from question "Java - when "this" is the only way to go?"


"I believe the reasoning behind it is that it allows the parameters to be named nicer by preventing shadowing of member variables"

from question "Programming style from "Game Coding Complete""

More flexible

"When you re not worrying about shadowing this is more flexible if the named of the object changes"

from question "Whats the difference between using 'this' and the object name for reference inside the object?"

Back to Home
Data comes from Stack Exchange with CC-BY-SA-3.0