In previous posts I've commented occasionally about integrating my LiveCode apps with HTML, PHP, and mySQL. I wish all programming environments were patterned after LiveCode. But, alas, they are not. Too bad because I've been programming in LiveCode long enough that I actually think in LiveCode. I need to get much more proficient in PHP and it dawned on me recently that I could leverage my LiveCode skills to do so. My idea is to first build a working prototype of functions or procedures I need to program in PHP with LiveCode. The idea being that I can work out the hard part - the logic - much more easily in LiveCode, then "convert" that logic to PHP code.
The idea of just creating an algorithm in everyday language is often just called pseudocode. The code doesn't actually work in any programming language, but it allows you to get to the heart of the logic without getting bogged down in syntax or rules. I have come to naturally write out my logic with LiveCode so these algorithms not only act as pseudocode, they are also work when plugged into LiveCode.
Here's a very simple example of some PHP code I wrote recently that took all of 10 seconds to write out first in LiveCode:
Stated in English: If the variable containing the information from the column (or record) downloaded from the database does not contain any information, then enter the phrase "Nothing entered." into that variable. Then, display or print that value on the screen with a line return after it.
Here is the PHP code I eventually wrote:
The LiveCode and PHP code aren't exactly equivalent in that I didn't actually need to use an if-then-else construction with LiveCode. But, just writing out what needed to happen in simple logic led me to the right PHP construction. What took me 10 seconds in LiveCode took about an hour in PHP because I am not fluent in PHP. I had to relearn that a period is used as the concatenation symbol. I had to relearn that /n is used to trigger a return (i.e. new line) on the screen. I had to relearn that a dollar sign is used to connote a variable. And so on.
Interestingly, in PHP there are several functions that address the idea of "emptiness" in a variable:
I have several other immediate PHP programming jobs that are much more sophisticated. I will again start with building a working version with LiveCode as a way to figure out the logic, then "convert" that logic into PHP code.
I think it will be a long time before I start to think in PHP.
The idea of just creating an algorithm in everyday language is often just called pseudocode. The code doesn't actually work in any programming language, but it allows you to get to the heart of the logic without getting bogged down in syntax or rules. I have come to naturally write out my logic with LiveCode so these algorithms not only act as pseudocode, they are also work when plugged into LiveCode.
Here's a very simple example of some PHP code I wrote recently that took all of 10 seconds to write out first in LiveCode:
if varDatabaseColumn is empty then put "Nothing entered." into varDatabaseColumn
put varDatabaseColumn&return after field "text"
Stated in English: If the variable containing the information from the column (or record) downloaded from the database does not contain any information, then enter the phrase "Nothing entered." into that variable. Then, display or print that value on the screen with a line return after it.
Here is the PHP code I eventually wrote:
if (empty($row_rsUser['rating_statement'])) {
echo "Nothing entered."."\n";
} else {
echo $row_rsUser['rating_statement']."\n";
}
The LiveCode and PHP code aren't exactly equivalent in that I didn't actually need to use an if-then-else construction with LiveCode. But, just writing out what needed to happen in simple logic led me to the right PHP construction. What took me 10 seconds in LiveCode took about an hour in PHP because I am not fluent in PHP. I had to relearn that a period is used as the concatenation symbol. I had to relearn that /n is used to trigger a return (i.e. new line) on the screen. I had to relearn that a dollar sign is used to connote a variable. And so on.
Interestingly, in PHP there are several functions that address the idea of "emptiness" in a variable:
- empty($var)
- isset($var)
- is_null($var)
I have several other immediate PHP programming jobs that are much more sophisticated. I will again start with building a working version with LiveCode as a way to figure out the logic, then "convert" that logic into PHP code.
I think it will be a long time before I start to think in PHP.
ReplyDeleteI am very happy when read this blog post because blog post written in good manner and write on
good topic. Thanks for sharing valuable information.
School Information Management System,
Online Fee Payment Integration
College Management System
Message
.
ReplyDeleteHi everybody, I hope you are doing good day. Dear admin I had scroll down your site and found it really useful for web development tools. Since I am a developer, I most often refer people to use best website in the town for web development. Your efforts are really appreciable. We also provide web development tool. Here is the link of our site jsononline
ReplyDeleteHi,
ReplyDeleteAwesome Post.
Such this post is very informative.
Thanks for sharing with us.
Php Web Development Company Bangalore | Hire Magento Developer In Bangalore | Internet Marketing Company in Bangalore | Magento Development Company Bangalore