07-23-17, 08:45 PM
|
#8
|
A Firelord
Join Date: Mar 2008
Posts: 463
|
Originally Posted by MunkDev
Spaghetti coding until I start to get headaches, then clean up. Rinse and repeat.
Seriously though, I just tend to live by some principles: - If a piece of code is called more than once, it needs a function.
- When you're expecting many elements that perform the same or nearly the same task, I use an object-oriented approach. Mixing in functions on widgets in Lua doesn't create much overhead, because you're only creating pointers to the original functions.
- Split the code into multiple files that are each dedicated to solving a specific problem.
- Error check everything and don't assume you did everything correctly and nothing's going break.
- Code should generally be written as a story that you can almost coherently read out loud. Avoid abbreviations unless they are absolutely clear.
|
^^^This!!!
|
|
|