Hello everyone,
From the moment I learned how to use functions, I've kind of been wondering whether I'm using them correctly or not. Considering I'm learning everything on my own, I don't have much reference to go by, other than things I find in a book.
What I wonder is if it is good programming practice to keep a particular task in a separate function? How do you decide what to keep, and what to do separate?
I find myself doing even menial tasks like:
1 2 3 4 5 6 7 8 9 10
|
void printTitle()
{
//some title here
}
int main ()
{
printTitle();
//more code
}
|
I could just have placed that thing inside the main() function. But for some reason I prefer to have as much of the real code outside of main(). I do not know why though, I just think it looks more organized that way.
Thing is, even if there are no disadvantages to it, is it still a good practice to do so? I don't want to end up doing this all the time and then having to unlearn it when I do start earning money for this.
I may be to hasty on this, as OOP is in the next chapter. It just bothers me when I write my code now :D