+ 4
For the C language. Does Having many Functions make your code "weak" or "not standard".
For example, getting the factorial of a number can be done iteratively or recursively (with function). So is it appropriate to use iterative method or recursive. I was writing a program for knights tour problem and I used 3 functions. Then I found out that it could be done with just main. So I started wondering whether my version was "weak" or "noob".
7 Respostas
+ 7
If you have a 5 line program printing out the factorial of a number, it's OK to do it all in the main function. If you expand the code to add more functionality, it's better to add more functions to make the code more modular and prevent the main function from being a so called God function as long as you are not in the process of optimising the code for speed and efficiency.
+ 6
Number of functions or numbers of lines of code doesn't play any role in efficiency of program.
+ 5
Larger programs generally have more functions and smaller ones fewer functions.
+ 4
Having many functions makes one's code be more modular I'm sure, not too sure what exactly defines strong or weak, standard or non-standard. I think such terms are individually defined, but I'm not a software designer, maybe someone else here has a theory about it, backed with facts and experience.
What I'm actually trying to say is, as a learner, don't be too concerned about the "norms and standards", there will come a time for that later. Learn to read and write now, laws and regulations later. Of course you can do so as you go, but don't overdo it, might slow you down even.
+ 3
Arsenic ok. That's good to know since C supposedly prioritizes efficiency.
+ 1
Ipang Thanks. I'll just work the way I know how.