more useful options | |
PerlMonks |
Advice please on variable naming style in modulesby isync (Hermit) |
on Aug 21, 2012 at 17:33 UTC ( [id://988803]=perlquestion: print w/replies, xml ) | Need Help?? |
isync has asked for the wisdom of the Perl Monks concerning the following question:
Is there some standard on how to name variables in nested modules? Again and again, I am unsure whether I should name my variables this way or the other way round.
One style is that the local variable of a module is called $self or $this. Seems to be the common style. So far so good. A problem arises when I use the local-module-var of the next level up within a nested module one level below. How should I name the former $self here? $toplevel_self? If I go down this path, I end up with some modules where I refer to a specific var by $self (probably the top-level module) and in other parts of my app, I name this var $that_toplevel_self, $parent or similar. This is especially awkward when the top-level $self contains some global config vars for my app. So, is there a good argument for always naming my var $self/$this? Or is the other style I exemplify below equally sane, or even more helpful in a nested modules environment? Any hints which style I should use to adhere to "good coding style", or readability, when other developers join my projects?
Some pseudo-code to explain what I am talking about:
Back to
Seekers of Perl Wisdom
|
|