Yesterday I was asked the question: "If we don't use XML, how else will we send hierarchical data through a POST?"
I knew there had to be a better way to send hierarchical data other than sending a massive string of XML containing all the necessary data. In PHP (as well as other common programming languages) POST data is categorized nicely into an array that contains all POST data that was passed from one page to another. However, at the company I work at, instead of assigning data to form fields or just using cURL to send variables with the appropriate data, we send one long and cumbersome XML string in a variable. Now, that wouldn't be so bad normally, but once that XML string reaches its destination, the variables are parsed out of the XML, assigned to variable data, and processed normally. Why is this extra step necessary? As far as I can tell, there is no useable reason to do this other than relying on XML to organize your data for later use.
Enter the multi-dimensional array. When dealing with hierarchical data, typically muti-dimensional arrays are used to organize the data into easy to use and very versitile means of extraction into other functions or objects without the need to parse out tiresome strings of XML.
The ways of programming seem to be shifting in this new world of open source "solutions" and fast-food style coding where quantity outweighs quality on a ratio so one-sided that bugs and errors are now considered normal operating procedure. Bypassing normal means of programming may speed up the process to get the job done faster, but there's a good chance that if you are using a method that could have been accomplished ten years ago by the people who started the ball rolling, it would be the standard if it was deemed effective, productive, and safe. However, certain methods have been established as the norm for a reason, most likely many reasons. And, while I will not dare assume that I can fathom all of the reasons why a specific method is prefered, the old adage holds true: "If it ain't broke, don't fix it."
I knew there had to be a better way to send hierarchical data other than sending a massive string of XML containing all the necessary data. In PHP (as well as other common programming languages) POST data is categorized nicely into an array that contains all POST data that was passed from one page to another. However, at the company I work at, instead of assigning data to form fields or just using cURL to send variables with the appropriate data, we send one long and cumbersome XML string in a variable. Now, that wouldn't be so bad normally, but once that XML string reaches its destination, the variables are parsed out of the XML, assigned to variable data, and processed normally. Why is this extra step necessary? As far as I can tell, there is no useable reason to do this other than relying on XML to organize your data for later use.
Enter the multi-dimensional array. When dealing with hierarchical data, typically muti-dimensional arrays are used to organize the data into easy to use and very versitile means of extraction into other functions or objects without the need to parse out tiresome strings of XML.
The ways of programming seem to be shifting in this new world of open source "solutions" and fast-food style coding where quantity outweighs quality on a ratio so one-sided that bugs and errors are now considered normal operating procedure. Bypassing normal means of programming may speed up the process to get the job done faster, but there's a good chance that if you are using a method that could have been accomplished ten years ago by the people who started the ball rolling, it would be the standard if it was deemed effective, productive, and safe. However, certain methods have been established as the norm for a reason, most likely many reasons. And, while I will not dare assume that I can fathom all of the reasons why a specific method is prefered, the old adage holds true: "If it ain't broke, don't fix it."

No comments:
Post a Comment