I'll start off by saying that, for the vast majority of the programs and utilities I write, I haven't yet exceeded 1k lines, and so haven't found the necessity for using library stacks outside of testing them while I was initially learning Lc.
My hats off to you for writing something that actually needs 4k lines in any format!
Having said that, my belief is that libraries are best suited for exactly what Craig says, functions / handlers that you -
* use often
* have worked all possible bugs out of
* have (hopefully) documented so less often used ones don't trip you up when you come back to them years later
kaveh1000 wrote: ↑Sat Aug 31, 2019 8:45 am
prefixes for handlers...
I'm hardly the poster boy for writing good code, but I only prefix variables. I agree with Andre's recommendation for naming them, if done correctly you shouldn't need to prefix it, the name will tell you what you need to know.
For naming variables, I go mostly with the old standard camel case method of 3 or 4 chars, then name (however long), for my own stuff. I find this is easiest to read, but again, I learned it a long time ago and spent many years using it. An example of my typical naming for variables would be (like I showed in the editor video) :
-- temporary - tmpVar
-- local - lclVar
-- global - gblVar
-- custom property - cpropProperty
...etc.
I use the same style of naming for handlers/functions/ object naming, mostly without dashes or underscores since the capital letter making the break obvious. For example :
-- field for text to be entered/changed - field "txtMyField"
-- field that is a label, button, or otherwise unchanged - field "lblField"
-- typical button - button "cmdOneShot"
{ or button "cmd156Shot" when using much longer numbers as part of the name}
...etc.
Doing this makes it easy to target specific controls with one line of code, AND has the added bonus of making it almost impossible to use a built in command, function, or object name. For example:
Code: Select all
on mouseEnter
if char 1 to 3 of the name of the target is "lbl" then set the backColor of the target to "green"
end mouseEnter
Here is an example (admittedly simple) of what I'm describing -
However, if you are looking to write variables today, as well as a pretty nicely formatted guide on scripting in general, I'd point you instead to Richard's excellent text on the subject -
http://www.fourthworld.com/embassy/arti ... style.html
In it, he covers a lot of topics. Here is the TOC -
Contents:
Introduction
General Scripting Techniques
Top-Down Handlers
Clarify Program Flow
Comment Effectively
Comments as Breadcrumbs: What? Bang! Hmmm
Code for Reuse
Code for Speed
Naming Conventions
Variables and Arguments
Handlers and Functions
Objects
As you can see, it covers quite a bit of ground, and comes from the knowledge of quite a few that have been around in this language enough to know it expertly, making it well worth the time to read.