LC App design theory?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
LC App design theory?
I was wondering if there are there any resources, links, for LiveCode app design? Where to place scripts in a stack, best practices, things to avoid, and so on?
Thanks
Thanks
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: LC App design theory?
Are you completely new to LC? If so, welcome.
But you need basic knowledge to be able to appreciate any answer you might get here.
Once you get the hang of LC, and can drive comfortably, even if not at breakneck speed, do ask that question again. It will not take too long.
Check out the scripting conferences: http://www.hyperactivesw.com/revscriptc ... ences.html
and http://livecode.byu.edu
There are other fine sites as well, written and maintained by LC advocates.
As well as the user guide, dictionary and lessons, all available in the "help" menu.
If you are a bit more experienced, please ask more specific questions.
Craig Newman
But you need basic knowledge to be able to appreciate any answer you might get here.
Once you get the hang of LC, and can drive comfortably, even if not at breakneck speed, do ask that question again. It will not take too long.
Check out the scripting conferences: http://www.hyperactivesw.com/revscriptc ... ences.html
and http://livecode.byu.edu
There are other fine sites as well, written and maintained by LC advocates.
As well as the user guide, dictionary and lessons, all available in the "help" menu.
If you are a bit more experienced, please ask more specific questions.
Craig Newman
Re: LC App design theory?
Avoid using global variables..
Re: LC App design theory?
Hi shaosean,
I was wondering why you advise against using global vars?
Are you advocating the use of custom properties instead?
I use global vars all the time and do not encounter any problems as long as you remember to add the deceleration at the top of each card etc. In fact doing so, I find reinforces in my memory that the global exists.
I was wondering why you advise against using global vars?
Are you advocating the use of custom properties instead?
I use global vars all the time and do not encounter any problems as long as you remember to add the deceleration at the top of each card etc. In fact doing so, I find reinforces in my memory that the global exists.
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: LC App design theory?
Globals are a matter of style. I prefer custom props, but now and then use them. Context seems to favor one over the other...
But that is a tiny issue with respect to the original question. Or is it?
Craig
But that is a tiny issue with respect to the original question. Or is it?
Craig
Re: LC App design theory?
Thanks for the answers.
Let me clarify a bit. I've built a few apps for my personal use, and have taught myself along the way. So, not completely new but self-taught and mostly feeling around in the dark.
I've also read a bit about smalltalk, looked at some of the books online. One thing that is both a pro and a con of that environment is that you get a lot of design theory right at the start: How long a method should probably be, how it should be named, what, generally, it should do, and moves into the fine details.
There were some books that kind of touched on this for hypercard, I have an old Goodman book where he talks about naming related objects the same thing if they reference each other: button "timeCode", field "timeCode", group "timeCode". That way a mouseUp on group, card or stack level can reference (field (short name of target)) and get the correct field. So I don't have to code a bunch of different mouseUps that do the same thing but reference different objects: buttons, fields, graphics, etc.
I was wondering if there were any updated material that dig into this kind of thing that was created after the 90s?
So questions like: Is it a good idea to name fields, buttons, groups the same thing? Should object names "haveNoSpaces" or be easier to use "with some spaces"? I can see how the later naming convention would be better. A script could easily shift between objects if objects were named "my field 6" by just adjusting word 3 of (short name of target).
So this kind of general ideas about app building was what I was wondering about. I understand that different people will have different approaches but learning what approaches people use would be insightful.
So, a more abstract question about style than solving a particular problem.
Thanks.
Let me clarify a bit. I've built a few apps for my personal use, and have taught myself along the way. So, not completely new but self-taught and mostly feeling around in the dark.
I've also read a bit about smalltalk, looked at some of the books online. One thing that is both a pro and a con of that environment is that you get a lot of design theory right at the start: How long a method should probably be, how it should be named, what, generally, it should do, and moves into the fine details.
There were some books that kind of touched on this for hypercard, I have an old Goodman book where he talks about naming related objects the same thing if they reference each other: button "timeCode", field "timeCode", group "timeCode". That way a mouseUp on group, card or stack level can reference (field (short name of target)) and get the correct field. So I don't have to code a bunch of different mouseUps that do the same thing but reference different objects: buttons, fields, graphics, etc.
I was wondering if there were any updated material that dig into this kind of thing that was created after the 90s?
So questions like: Is it a good idea to name fields, buttons, groups the same thing? Should object names "haveNoSpaces" or be easier to use "with some spaces"? I can see how the later naming convention would be better. A script could easily shift between objects if objects were named "my field 6" by just adjusting word 3 of (short name of target).
So this kind of general ideas about app building was what I was wondering about. I understand that different people will have different approaches but learning what approaches people use would be insightful.
So, a more abstract question about style than solving a particular problem.
Thanks.
Last edited by monki on Thu Mar 09, 2017 12:39 am, edited 1 time in total.
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: LC App design theory?
OK.
I generally assign related controls with related names. For example, in a project I am working on, I have multiple groups of fields, three fields high and twelve long. That is, groups of 36, like a row of connected three story buildings. I name the fields in the "top floor" of the first group "top,1,1", top,1,2", etc. The "middle" floor would be "middle,1,1", "middle,1,2", etc.
In this way if the user clicks on fld "bottom,4,8" I know all about its neighbors, especially those in the same "building". I could for example, put new data into fld "top,4,8", that field being the one two above the target by simply (pseudo):
A single mouseUp handler in the card script does just that. Anyway, that sort of thing.
Craig
I generally assign related controls with related names. For example, in a project I am working on, I have multiple groups of fields, three fields high and twelve long. That is, groups of 36, like a row of connected three story buildings. I name the fields in the "top floor" of the first group "top,1,1", top,1,2", etc. The "middle" floor would be "middle,1,1", "middle,1,2", etc.
In this way if the user clicks on fld "bottom,4,8" I know all about its neighbors, especially those in the same "building". I could for example, put new data into fld "top,4,8", that field being the one two above the target by simply (pseudo):
Code: Select all
put newData into fld "top" & "," & item 2 of the short name of the target & ",' & item 3 of the short name of the target
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9837
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: LC App design theory?
Hi monki -
There's a lot of dogma about global variables, among users of many languages. But most languages still provide them, so there must be some value in using them. Shao Sean's guidance is appropriate, avoiding absolutes to suggest mindfulness instead. Here's my own take on globals, and the practical considerations of their alternatives:
http://forums.livecode.com/viewtopic.ph ... 57#p129457
As for more general questions of structure and naming, how much of the User Guide have you read? With more than 650 pages it's pretty beefy and almost no one reads the whole thing, but you may find the chapter "Programming a User Interace" worth a skim, esp. the section in it titled "Referring to Objects".
There's a lot of dogma about global variables, among users of many languages. But most languages still provide them, so there must be some value in using them. Shao Sean's guidance is appropriate, avoiding absolutes to suggest mindfulness instead. Here's my own take on globals, and the practical considerations of their alternatives:
http://forums.livecode.com/viewtopic.ph ... 57#p129457
As for more general questions of structure and naming, how much of the User Guide have you read? With more than 650 pages it's pretty beefy and almost no one reads the whole thing, but you may find the chapter "Programming a User Interace" worth a skim, esp. the section in it titled "Referring to Objects".
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: LC App design theory?
Great, Thanks.dunbarx wrote:OK.
I generally assign related controls with related names. For example, in a project I am working on, I have multiple groups of fields, three fields high and twelve long. That is, groups of 36, like a row of connected three story buildings. I name the fields in the "top floor" of the first group "top,1,1", top,1,2", etc. The "middle" floor would be "middle,1,1", "middle,1,2", etc.
In this way if the user clicks on fld "bottom,4,8" I know all about its neighbors, especially those in the same "building". I could for example, put new data into fld "top,4,8", that field being the one two above the target by simply (pseudo):A single mouseUp handler in the card script does just that. Anyway, that sort of thing.Code: Select all
put newData into fld "top" & "," & item 2 of the short name of the target & ",' & item 3 of the short name of the target
Craig
I see that you're using itemized object names, interesting idea. Never thought of doing that, might start though.
Re: LC App design theory?
I usually use custom properties at the stack level for any global variables, then use commands and functions for set, and get. That's worked well for me. Think I got the idea from the newsletter article you linked in the post. It's a great idea, I use it all the time. I didn't know about the lockMessages issue, so that's something to keep in mind. But so far it hasn't come up.FourthWorld wrote:Hi monki -
There's a lot of dogma about global variables, among users of many languages. But most languages still provide them, so there must be some value in using them. Shao Sean's guidance is appropriate, avoiding absolutes to suggest mindfulness instead. Here's my own take on globals, and the practical considerations of their alternatives:
http://forums.livecode.com/viewtopic.ph ... 57#p129457
As for more general questions of structure and naming, how much of the User Guide have you read? With more than 650 pages it's pretty beefy and almost no one reads the whole thing, but you may find the chapter "Programming a User Interace" worth a skim, esp. the section in it titled "Referring to Objects".
I don't think globals are evil, just dangerous. However, I have thought about using a global or two to create my own version of the "it" variable, but it would only be set by me. As long as its use is compartmentalized into small handlers, I don't think it shouldn't be a problem. I declare all my variables using "local", but there are times when I just want to do a little thing. I could use "it" for that. But it could be safer to have something that the environment doesn't use. I guess a script variable would work better for that.
I've read parts of the User Guide, but no, I haven't read all of it. I will take a look at that section again though.
Thanks.
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: LC App design theory?
It is just a way to parse and create references "internally". Anything would do.I see that you're using itemized object names,
Be careful with "it", and even more so with "the result". They have a habit of changing on you. Store them somewhere immediately unless you really are sure...
But it sounds like you are well ahead of the level of questions you are asking. This forum is for just that sort of thing, of course, and others will likely be interested. I would just say that as you use LC more, you will find your own comfort level.
Craig
Re: LC App design theory?
More a matter of preference I guess.. I personally prefer a library stack with a nicely defined API to have access to the data.. So many different ideas about programming styles, just find one that works for you and go for it, but for new coders, I would recommend against globals as it may end up causing them some wondering about why something does/doesn't work..AndyP wrote:Hi shaosean,
I was wondering why you advise against using global vars?
Are you advocating the use of custom properties instead?
I use global vars all the time and do not encounter any problems as long as you remember to add the deceleration at the top of each card etc. In fact doing so, I find reinforces in my memory that the global exists.
-
- VIP Livecode Opensource Backer
- Posts: 9837
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: LC App design theory?
There is only one immutable truith: no dangling "then"s.shaosean wrote:So many different ideas about programming styles...
This:
Code: Select all
if Something() then
SomethingElse
end if
Code: Select all
if Something()
then
SomethingElse
end if
#TheStruggleIsReal
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn