Creating a Code Library
Posted: Tue Sep 13, 2011 9:55 pm
I have a question regarding LiveCode’s code library paradigm. I came from Java and Python, so I’m used to organizing my code into libraries to make future projects easier. However, I’m not 100% sure how to achieve this in LiveCode yet. To be honest, working with LiveCode feels like I’m working backwards. That’s not a criticism, though. It just feels weird designing and then coding.
Everything is so visually oriented; I have the opposite reaction I normally possess while coding and then trying to map that into a visual program. With LiveCode it’s just the opposite. I start with a visual representation and then map out the code. While this makes UI design much more efficient, it leaves me wondering how to best organize my code into manageable libraries. Fortunately, though, the manual mentions this as a suggestion on page 159 (UserGuide, 2011).
Unfortunately, it doesn’t go into a lot of detail. It specifies that a code library is created by placing the desired handlers into any object available to your stack. But then it seems to get somewhat ambiguous. Such as the purpose behind the insert script and the start using commands. It says, “Typically you would run one of these commands as your application is starting up, so that all the scripts can access the libraries you require” (UserGuide, 2011).
It then goes on to describe front scripts and back scripts -- of which I understand. What I want to know is what are some general guidelines for creating a well organized library like this?
I’m not sure, but here’s what I think the manual is saying. Say, for example, I am creating a library for interacting with SQLite. I would create a new stack and name it something like SQLLib. Then in the main stack, I could map out my custom commands and functions. Then if I ever want to use anything it defines, it’s simply a matter of referencing the SQLLib stack whenever appropriate. But if that is the case, and a stack serves entirely as a library, what good purpose do sub-stacks serve for such a stack? I suppose it could serve to further break libraries down into sections. But, again, I’m not sure. Your advice is greatly appreciated.
Thanks for your time
Sincerely,
Sanoski
Everything is so visually oriented; I have the opposite reaction I normally possess while coding and then trying to map that into a visual program. With LiveCode it’s just the opposite. I start with a visual representation and then map out the code. While this makes UI design much more efficient, it leaves me wondering how to best organize my code into manageable libraries. Fortunately, though, the manual mentions this as a suggestion on page 159 (UserGuide, 2011).
Unfortunately, it doesn’t go into a lot of detail. It specifies that a code library is created by placing the desired handlers into any object available to your stack. But then it seems to get somewhat ambiguous. Such as the purpose behind the insert script and the start using commands. It says, “Typically you would run one of these commands as your application is starting up, so that all the scripts can access the libraries you require” (UserGuide, 2011).
It then goes on to describe front scripts and back scripts -- of which I understand. What I want to know is what are some general guidelines for creating a well organized library like this?
I’m not sure, but here’s what I think the manual is saying. Say, for example, I am creating a library for interacting with SQLite. I would create a new stack and name it something like SQLLib. Then in the main stack, I could map out my custom commands and functions. Then if I ever want to use anything it defines, it’s simply a matter of referencing the SQLLib stack whenever appropriate. But if that is the case, and a stack serves entirely as a library, what good purpose do sub-stacks serve for such a stack? I suppose it could serve to further break libraries down into sections. But, again, I’m not sure. Your advice is greatly appreciated.
Thanks for your time
Sincerely,
Sanoski