Is there any performance implications if I do either of these:
def do_something(user, article)
...
end
versus
def do_something(user_id, article_id)
..
end
I prefer passing objects as I might need other attributes down the road.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes
Both method calls will take about the same amount of time.
(It’s good to be aware of performance consequences and you asked a reasonable question, but even so, the standard disclaimer1 about early optimization technically applies.)
1.
First, make program work.
Then, profile.
Finally, and maybe, optimize.
Donald Knuth said:
We should forget about small
efficiencies, say about 97% of the
time: premature optimization is the
root of all evil.