Login Register






Tutorial The do's and don'ts of programming filter_list
Author
Message
RE: The do's and don'ts of programming #8
Quote:Some languages (PHP, javascript, python, etc) allow you to declare a variable at runtime, and whenever you want. This is a neat little tool, but it isn't used as it should be. In essence, you should know [b]EXACTLY what variables you need from the start. Dynamic definitions is a scoping feature, NOT a convenience. If you have a function that does something, and you need three variables, don't define them the first time you use them, define them at the top of the function! This goes for languages like C as well (older versions actually forced this). I have been caught a few times forgetting a variable name and digging through it, it sucks, avoid it.

Could you give a python example with this. I haven't used python in a while and I just want to make sure I'm understanding what you mean. Thanks.
"If you look for the light, you can often find it. But if you look for the dark, that is all you will ever see.”


Reply





Messages In This Thread
The do's and don'ts of programming - by phyrrus9 - 08-23-2016, 11:35 AM
RE: The do's and don'ts of programming - by 0M4R - 08-27-2016, 03:39 PM
RE: The do's and don'ts of programming - by Nil - 08-27-2016, 06:12 PM
RE: The do's and don'ts of programming - by Nil - 08-28-2016, 04:03 AM