
Coding Styles
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Coding Styles
Hi everyone....I have been using LC for about a year and a few months now and I gotta say, I have been bitten by the LC bug and love coding any chance I can. I am very much the novice coder as some of you that have helped me in the past already know!
I was thinking last night about some of the help that I have received in the past, and a thought occurred to me about how people go about structuring their code. What I mean is this....I recently received some help on a topic about moving images on the screen for IOS and dropping them into a graphic rectangle. The image was then resized to fit the rect of the graphic and it all worked great. The other nice thing that it did was allow the user to swap image positions on the screen thus allowing the user to arrange the images to however they liked. I took a look at the code of the person who helped and decided that I was not yet that advanced to completely understand how they did it, so I tried doing it another way and had great success. Overall, when it came to moving images and swapping their positions on the screen , I went with the "intersect" command and after a few hours of playing was able to get all my images to behave like I wanted. I went back and looked once again at the code that was provided by the other person and wondered why they wrote a very complex series of commands to do what I did with some very basic coding. It led me to wonder this...am I doing something wrong and that person (who obviously had more experience than me) was doing it the correct way? It just seems like to me that if I dig deep enough in the dictionary and apply some very basic coding practices, I can accomplish the same thing. I know without examples to provide for those who read this, it's difficult to know what I mean, but I was just curious to see what other people think about their own coding style.

Re: Coding Styles
Hi.
This is all quite normal. You might see the "complex" offering of another, regardless of their ability, and your compact and clever solution, as what it really is: a testimonial to the power and flexibility of LC, in that there are many different ways to solve a problem. Examine some of the longer threads that deal with basic questions (not queries about odd library plug-ins). You will find the evolution of comment explores different tacks, and often ends up with a handful of viable options.
I usually dash off quick offerings to this forum with some consideration, though often with little really careful thought, and almost never with any actual testing. So I often find that someone else's different approach is much more elegant and compact than what I first thought of. Sometimes, even, I am that other person. We all pursue compact, robust code, that is easy to read, that can be extended or modularlized, and that can be deciphered when you go back to it later.
That you are asking this is a sign you have joined the ranks of the blessed. Don't overFret. rather, enjoy...
Craig Newman
This is all quite normal. You might see the "complex" offering of another, regardless of their ability, and your compact and clever solution, as what it really is: a testimonial to the power and flexibility of LC, in that there are many different ways to solve a problem. Examine some of the longer threads that deal with basic questions (not queries about odd library plug-ins). You will find the evolution of comment explores different tacks, and often ends up with a handful of viable options.
I usually dash off quick offerings to this forum with some consideration, though often with little really careful thought, and almost never with any actual testing. So I often find that someone else's different approach is much more elegant and compact than what I first thought of. Sometimes, even, I am that other person. We all pursue compact, robust code, that is easy to read, that can be extended or modularlized, and that can be deciphered when you go back to it later.
That you are asking this is a sign you have joined the ranks of the blessed. Don't overFret. rather, enjoy...
Craig Newman
Re: Coding Styles
KennyR...
There is not really any 'right' or 'wrong' way to write your scripts... if it works for you then all is good !...
Having said that, there are times when a script will produce the result you are after a little faster than another one... and I guess that all the little bits of time saving do add up in the end...
Then there are others who prefer using custom properties to hold values rather than using global variables, for example...
I generally tend to think that if your code works, is readable and can easily be understood by others then there is no problem...
Dixie
There is not really any 'right' or 'wrong' way to write your scripts... if it works for you then all is good !...


I generally tend to think that if your code works, is readable and can easily be understood by others then there is no problem...
Dixie
Re: Coding Styles
I think it is exciting to discover a really elegant and sometimes simple solution to a problem that previously had taken so much code and complexity. It is part of learning new ways to problem solve or new ways to look at problems.
It is like spending so much time at first learning about the set command, properties, boolean true/false to set something not visible. Then someone comes along and suggests the simple "hide" command. No way that works is wrong but some ways are simply better.
The neat thing, is that none of it is wasted time. You end up with more "tools" in your "toolbox". And you learn to appreciate elegant code and simplicity.
It is a fun and challenging process. That is why I enjoy programming, especially with LiveCode
It is like spending so much time at first learning about the set command, properties, boolean true/false to set something not visible. Then someone comes along and suggests the simple "hide" command. No way that works is wrong but some ways are simply better.
The neat thing, is that none of it is wasted time. You end up with more "tools" in your "toolbox". And you learn to appreciate elegant code and simplicity.
It is a fun and challenging process. That is why I enjoy programming, especially with LiveCode
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/
Re: Coding Styles
Hi All,
Richard wrote an article about that:
http://www.fourthworld.com/embassy/arti ... html#intro
Best
Jean-Marc
Richard wrote an article about that:
http://www.fourthworld.com/embassy/arti ... html#intro
Best
Jean-Marc
https://alternatic.ch