Function before or after the "main" ? Which are really better?

I know in this video it is suppose to be after the main, the better. But I have started a C# course at my school and the teacher prefer to have the function/methods before the main.

So I am a little confuse which one is really better. I agree with this video but just to be sure ?

That’s basically asking whether left-wing or right-wing or middle is better politics.
Whether Apple’s taste better than oranges, better than manderines…

Everyone has his own opinion and there’s no definite correct answer.

The compiler doesn’t care, so you get to choose yourself.

My opinion:

  • If at all (normally i put functions in a different file or namespace, because i don’t like globally available functions) I put them after the main, because the main dictates in what order/context which function is executed.

  • This way any reader always reads the main first, and can look up the function definitions in the order they are supposed to be executed, which makes understanding a lot easier. (I suggest starting by reading the main-function anyways, unless you want to read random function definitions, with no context to put them in)

Privacy & Terms