Getting started with libraries
Graham Samuel
livfoss at mac.com
Sun Mar 19 08:47:16 EST 2006
Folks
Recent defences on the list of RunRev's capability with libraries has
made me realise how much I've missed out by not organising my own
work with libraries in mind. I would now like to make the move. but
I'm finding it quite hard to decide how to get started. As in the old
joke, to get there I shouldn't really have started from here... but
there it is.
What I have is a few apps which work and have users etc, and which
contain common elements. Up to now these common sections were created
by wholesale copying of stacks and bits of code from a finished app
to the next one to be developed. I find this is such an awkward
process that I don't keep all the apps up to date in parallel. For
example in App 1, I have devised a way for the user to register and
enter a serial number to get a fully functional version of the
program; I copied this code into App 2, a process which was pretty
clumsy in the first place because App 1 and App 2 can't have ANY
stacks with the same name (unless I open two copies of RunRev, but
for some reason I'm nervous of this idea). Then as I developed App 2,
I improved on the stuff I got from App 1. But generally App 1 doesn't
benefit because it's too much of a hassle to retrofit the improved
code. Now if I did all this with libraries, I would be much better
off, since the most up to date version of any library could be
retrofitted without problems.
So for me the issue is how to reach this point from where I am today.
Has anyone any advice about shifting my existing code into libraries
without having to massively restructure my existing apps? So far all
I have thought of is to remove the 'common' code to a library but to
retain the handler that was in the original app simply as a wrapper -
a wrapper handler would look like
on myOldHandler para1, para2
do myLibraryStuff para1,para2
end myoldHandler
However I have been (I suppose) rather careless with ways of passing
values, using various techniques including setting globals, specific
fields etc. If the library is not to have too many side effects then
I have to generalise those routines too, and that's the bit which I
would like to do as efficiently as possible. Maybe it's just a messy
job and that's all there is about it, but I'd like to know what other
people think.
TIA
Graham
----------------------------------------
Graham Samuel / The Living Fossil Co. / UK and France
More information about the use-livecode
mailing list