In languages where you have a choice, is it better to put the main function/method/code at the top or bottom? -


When you are writing a program that contains a small key argument that tells a bunch of support functions, you Either select the main argument at the top or bottom of the file (we allow this language either.) Which is better? Should I put my main argument in the beginning of the file or the end after all the initial tasks?

I think it's just a matter of personal preference that I would like to put it on top, So as soon as you open the code, you can see what it is doing and then go to the definitions of the methods from there. I think it makes more sense, to see a file open and a random bunch of methods and scrolling down to see them actually called.

As I said, all its choices though. Either:

  function myMain () {methodOne (); MethodTwo (); MethodThree (); } Function methodon () {// code here} function method two () {// code here} function method three () {// code here}  

or:

  function methodon () {// code here} function method two () {// code here} function method three () {// code here} function myMain () {methodOne (); MethodTwo (); MethodThree (); }  

Comments