views:

44

answers:

2

I hesitate between using the name of the current setter versus using a common name (such as $value) for all setters.

// Style 1
function set_section($section);

// Style 2
function set_section($value);
A: 

I'd go with value since it's the same name that is being used in .NET.

Hamid Nazari
+4  A: 

Name it what the parameter value represents. If it’s a section name, use name or section name; if it’s a section number, use number or section number; if it’s some kind of section itself, call it section.

Gumbo
I guess I'll have to change the setter function name to "set_section_name". Then the function definition would look like - function set_section_name($section_name).
Emanuil
@Emanuil: You don’t need that redundancy. If your method name does also specify the entity the method is called on, you can omit it in the parameter name. So I would just use `set_section_name($name)`. But if you have a method that has multiple entities that need to be distinguished between, use more verbose names like in `set_names($section_name, $subsection_name)`. But again, this does all depend on what entity `set_section_name` is called on.
Gumbo
@Gumbo: Thanks! That's very helpful.
Emanuil