Page 1 of 1

Best way to manage 35 variables?

Posted: Fri Dec 03, 2010 11:54 pm
by Tchapman
I have been sorting out how to manage around 35-40 variables between a wifi device and end users over the internet. To do this I set up a MYSQL db on my website, and have some test code in php that will update and get from the db based on what is coming in from the POST commands.

Currently I am using for testing something like this from the microprocessor device that talks to wifi via UART:

POST$/dbaccess.php?

Then the processor sends out whatever it wants to send based on what needs to happen. Below it just sends out a lot of test vars and data:

Code: Select all

ser.str(2, string("A=1&B=2&C=3&D=-2500555123&E=5&F=6&G=7&H=8&I=9&J=10&K=11&L=12&M=13&N=14&O=15&P=16&Q=17&R=18&S=19&T=20&U=21&V=22&W=23&X=24&Y=25&Z=26")) 
The php at the site does some updating to several locations on the database, and echos all the variables back to the wifi device just so I can monitor that it is getting it in tact.

The plan is to have the sifi device updating the db as anything changes on it, and the end user can monitor the values and understand what is going on, plus the the user can update the variables, and the wifi can get the changes and store them.

Is using the example above of sending all ( or in some cases just some) variables using a scheme like a-z considered practical or is there a better way to do it? I need to keep things ultra simple for now since I am just starting.

Re: Best wat to manage 35 variables?

Posted: Sat Dec 04, 2010 1:57 am
by Christopher
Tchapman wrote:Is using the example above of sending all ( or in some cases just some) variables using a scheme like a-z considered practical or is there a better way to do it? I need to keep things ultra simple for now since I am just starting.
I'm not sure that practical has anything to do with it. Clear variables names are mainly to improve maintenance and reduce errors. If the letters A-Z are clear and maintainable as parameter names then this scheme is fine.

Re: Best way to manage 35 variables?

Posted: Sat Dec 04, 2010 7:36 am
by Tchapman
Thanks. I guess I am trying to see if there is a more elegant way to send the variables back and forth. This method works and I do intend to change the names to make it easier to remember what is what.

Re: Best way to manage 35 variables?

Posted: Sat Dec 04, 2010 7:48 pm
by Christopher
Elegant is a little subjective. Some programmers might prefer for you to post JSON or XML in a single variable. Others might think using HTTP params is cleaner because it is one less thing to parse. Other factors may also affect your decision.