View Single Post
Old 10-21-2019, 12:56 PM   #334
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,430
Default

Quote:
Originally Posted by TonE View Post
plus how to set their parameters correctly, some start counting with 1, some with 0. Somehow this is the bad part of the whole lua story.
Any functions provided by Lua use 1-based indexes. The Reaper API (reaper.___, gfx.___) uses 0-based indexes because the API comes from C++ and has to work EEL and Python, all of which use 0.

Quote:
The main idea of a script should be understandable at first look, not looking like a cryptical task, splitting the main task into sub functions.
Splitting tasks into smaller functions is critical for making code easy to write, debug, and maintain. There are entire books devoted to this idea.

The original version of my GUI library was all in one file with functions that were hundreds of lines long, and it was a nightmare to work with. The version I'm working on now is split into a few dozen files, I think there might only be one function over a hundred lines, most are a dozen or less, and I'm able to make changes much more quickly while knowing exactly what other parts of the code have been affected.

That said, naming functions clearly is also a valuable skill and is unfortunately overlooked quite often.
Lokasenna is online now   Reply With Quote