luzif3r Posted April 22, 2008 Share Posted April 22, 2008 i finished writing a huge function and after careful review figured i break it down into several key functions to save space , readability, etc. now i read that it is advised to use locals but i would have to pass over unseemingly many parameters to my functions, which instead could just be global vars. saw it in several other udfs too, but im unsure what is better gist of my rambling: many globals ok/big nono/some ok ? Link to comment Share on other sites More sharing options...
monoceres Posted April 22, 2008 Share Posted April 22, 2008 When I write functions I like to see them as independent pieces of code that works regardless of how a function before behaved, and I also like to be able to change one function without having to consider the other functions in my script. This is somewhat broken if you decide to go with many globals since other functions may interfer with data that other functions is supposed to get. This could make debugging hard. But on the other hand, passing around data that most likely never changes is just plain stupid. I guess a mixture is the best. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
luzif3r Posted April 22, 2008 Author Share Posted April 22, 2008 Thanks for the reply monoceres. My subfunctions will only be called by my bigger function which is the only one that should ever be called from outside anyways. So i will go for some globals. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now