Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 40 Online
OpenStudy (anonymous):

When is it a good idea to build a new function for an operation?

OpenStudy (anonymous):

As in, "for how small of an operation is it worth building a function?" Does it depend on how many times you're going to use it?

OpenStudy (shadowfiend):

Often yes, it's advised that you write a function as soon as you need something more than once. Modern compilers can generally `inline' code -- meaning that they can detect when a function is relatively short and replace the function call with the code in the function itself, thus removing any performance impact from having `too many' function calls. This is, as usual, something you get a feel for, but small functions are not something to be afraid of. If what it does is not particularly evident, you can move a piece of code into a function so that you can give the function a descriptive name and then when it's used the code is clearer.

OpenStudy (anonymous):

Thanks!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Raye14: What pfp should I use the pfps will bc in the comments
14 minutes ago 11 Replies 0 Medals
Jasonisyours: any tips on how to get better at art
5 minutes ago 9 Replies 3 Medals
zariahispretty: How Do I get my old account back if password not working
10 hours ago 9 Replies 1 Medal
Raye14: Why do people like to hurt me
4 hours ago 17 Replies 3 Medals
XQueenFAMARIX: WHO u choosing Polo G or LILTJAY ud83eudd14?
1 hour ago 14 Replies 0 Medals
JuneTheAssasin2923: Does anyone know anything about literary analyisis papers?
11 hours ago 8 Replies 1 Medal
xEdwinX: what are peoples thoughts on suicide
10 seconds ago 44 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!