Hi Folks,
I am trying to determine the best way to organize and structure my code to write an application that will work on mobile devices and the desktop. I am thinking that a good design might go as follows:
1. Use the Mainstack script to get the screen size, platform etc. on preOpenStack and set those values as global variables.
2. Use the Mainstack script to call a specific card from OpenCard, based on the values derived from step 1, above.
3. Use the Mainstack script to provide common user defined functions that can be used from the platform/design specific card layouts.
Any thoughts, tips, pointers to documentation would be greatly appreciated. I have been programming a long time with more traditional languages but am completely new to LiveCard, and quite enjoying it.
Thanks,
Daryl
Design patterns
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 27
- Joined: Wed May 29, 2013 10:32 am
Re: Design patterns
The main thing when designing a stack for a purpose is to set it out in a way that is logical to you.
Use notes on functions which you may forget what they do either using hash or double dash(-).
Do not be afraid to space code of in the script and mainly just enjoy a fresh interface!
Use notes on functions which you may forget what they do either using hash or double dash(-).
Do not be afraid to space code of in the script and mainly just enjoy a fresh interface!

Code: Select all
# This is a note
Code: Select all
-- So is this
Getting there... Very slowly 

Re: Design patterns
It is very common to see developers setup an application structure in LiveCode quite similar to what you described. The mainStack in often nothing but an 'initialisation stack': it displays a splash screen, loads all needed libraries, and closes itself. Libraries that are loaded during initialisation can include code that looks after global values - ie., a localisation library - so you don't really have to put any 'global' code into the mainStack itself.
There is also an entire section in this Forum titled 'Software Development Cycles', where some experienced developers hang out, and can probably give you more pointers in terms of different application architectures for different kinds of projects.
I hope this helps!
There is also an entire section in this Forum titled 'Software Development Cycles', where some experienced developers hang out, and can probably give you more pointers in terms of different application architectures for different kinds of projects.
I hope this helps!

Re: Design patterns
Hi Icouto and Ninjabunny and thank you for your thoughts and suggestions. I certainly believe that good code should have good comments. When programing in LiveCode I have started to develop the habit of using the -- comments for documentation commentary and # comments for temporarily pounding out code. I just learned that you can also use two double slashes for comments // as in C++, Java and other languages, as well as the multiline comment markers /* and */ which I think is great. I kind of just stumbled on those by accident yesterday.
I will certainly visit the 'Software Development Cycles' forum to see what I can learn from there. I think I need to learn more about libraries and non-windowed scripting environments available in LiveCode.
Best Regards,
Daryl
I will certainly visit the 'Software Development Cycles' forum to see what I can learn from there. I think I need to learn more about libraries and non-windowed scripting environments available in LiveCode.
Best Regards,
Daryl