At 7/1/08 11:29 PM, Fugli wrote:
Anyway I wanted to know if there are any major rules to writing functions that maybe I never learned. Just recently I figured out not to use variables with the same name across functions, even if you don't intend to use it outside of those functions.
you mean, if you use "foo" in functionA, you cant use "foo" in functionB. there is no rule that says that, and anyone claiming that is absolutely wrong.
But even since then I've had more bugs in my programs. I was thinking there might be something I never learned. Any tips or tricks on writing them? If you call a function within a function does it wait for the called function to finish before continuing on?
programs execute linearly, so to speak. if you invoke a function, it will jump to that function, and then come back to where it left off. it will "wait for you", in so few words.
do parameters all have to be named differently across methods? I like to keep my programs organized and I'm beginning to think now that they aren't so much. any advice is appreciated.
parameters can be named the same across different functions. just try to remain organized and focused. if you can read your code, youre probably fine at this point. some people stick to certain conventions in an effort to make code more readable by other people.