How to set up a library?

Curry Kenworthy curry at pair.com
Fri Jan 1 00:55:18 EST 2021


Ben:

 > What is the best way to structure a library these days?

Flashback to an interesting conversation, when LiveCode Ltd (or RunRev 
Ltd) asked me, "what is a library?"

Not kidding; real question. It's like Newton Ltd asking you, "what is 
gravity?"

That opened my eyes to how libraries have been underappreciated and 
underpromoted at times, even at the very top of the LC community.

So I'm happy to see a thread about libraries. Thanks for starting it.

Best way is most efficient way. What's most efficient depends on your 
current or desired workflow.

 > Currently I've got buttons with a script, and a 'mouseup' handler
 > to 'insert the script of me into back' in my object library.
 > But I don't think that's very modern.

Neither way is extremely modern. But modern shouldn't be the overriding 
criterion for judging good design. Very true that good design is often 
modern, but conflating the two would be missing the point.

Start using, insert script into - both introduced in 1.0, if the 
dictionary serves. There's nothing less modern about insert.

Yet I've always preferred "start using." It suits my own style of 
organizing code (stacks or substacks) and loading it into memory.

Not necessarily better; again depends on YOUR workflow and overall 
organization methods. And where you need the code in the message path.

I've seen great button script inserts. (Although plenty of bad ones. 
Especially when inserting into front, it's a must to make sure the 
inserted code is pretty darn good.)

And I've seen terrible code with start using! It's possible to really do 
it badly. But I'm biased in favor of start using for most work.

 > What's the right way to do it? Especially if I want to share it?

So it's kind of a Ford/Chevy or AK/AR question. Used well, either will 
do. Either way, make sure initialization happens only once, don't tread 
on the user and seize control, try to anticipate how different users 
work in LiveCode and structure their scripts, etc. Don't duplicate code. 
And get a testing partner; he or she is a force multiplier.

But if modern IS to be the overriding criterion - peer 
pressure/trends/fads - I'd say cool kids better use git, script-only 
stacks, AND also plenty of behaviors which were introduced much later 
than libraries themselves. All together. And don't forget to make it a 
MVP. Otherwise behind the times, not kewl fewl. :)

Good topic.

Best wishes,

Curry Kenworthy

Custom Software Development
"Better Methods, Better Results"
LiveCode Training and Consulting
http://livecodeconsulting.com/




More information about the use-livecode mailing list