From: Zhenning Guan on
def method_1(options ={})
if some_conditions
options = {:method_2 => true}
method_2(options)
end

method_3(options)
method_4(options)
end

def method_2(options ={})
# some code
end


method_1({:method_1 => true)

+++++++++++++++++++++++

in some_condition, the variable options is most significant, but we use
temporary variable name options, it would rewrite options in method_1.
what would you do to name this variable?

t_options?
temorary_options?
--
Posted via http://www.ruby-forum.com/.

From: Robert Klemme on
On 04/02/2010 10:01 AM, Zhenning Guan wrote:
> def method_1(options ={})
> if some_conditions
> options = {:method_2 => true}
> method_2(options)
> end
>
> method_3(options)
> method_4(options)
> end
>
> def method_2(options ={})
> # some code
> end
>
>
> method_1({:method_1 => true)
>
> +++++++++++++++++++++++
>
> in some_condition, the variable options is most significant, but we use
> temporary variable name options, it would rewrite options in method_1.
> what would you do to name this variable?
>
> t_options?
> temorary_options?

I would not name it at all.

def method_1(options ={})
if some_conditions
method_2(:method_2 => true)
end

method_3(options)
method_4(options)
end

Btw, I have a nagging feeling that what you are doing might not be such
a good idea. But since we do not have any more context that's difficult
to substantiate.

Kind regards

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
 | 
Pages: 1
Prev: Padrino Webapp Framework
Next: require rubygems