Rules
1. It should not both return a value or perform some side-effect. It should only do one.
Eg:
Your method should not do this
def do_multiple(array)
array << "another_element"
end
The method return a modified array , at the same time, mutates the original array.
2. It should very limited things at a time. It should do one thing at a time.
3. If it mutates a value, use "!"
4. If it print something , use keywords like "say_xxx" or "print_xxx"
5. A good program is built with many small methods.
1. It should not both return a value or perform some side-effect. It should only do one.
Eg:
Your method should not do this
def do_multiple(array)
array << "another_element"
end
The method return a modified array , at the same time, mutates the original array.
2. It should very limited things at a time. It should do one thing at a time.
3. If it mutates a value, use "!"
4. If it print something , use keywords like "say_xxx" or "print_xxx"
5. A good program is built with many small methods.
Comments
Post a Comment