Loading ...
Sorry, an error occurred while loading the content.

89JSON as a function parameter

Expand Messages
  • TCQ
    Aug 20, 2005
      Greetings fellow JSON Lovers.

      I have been spending building a great deal of complex Product/Business
      workflow wizards and tools that are required to handle tons of data
      and great deal of client side functionality.

      As a result, many functions and methods have gotten to require longer
      and longer set of parameters. The worst case yet is about 12
      parameters with some being optional. In these cases, the calling code
      gets more and more un-readable as you add args. Also optional entries
      must have null ("") values all over the place making for unneeded code.

      With my ultimate goal of having clean and maintainable code, I have
      started using using json to pass the parameters and data to the

      . obj.init(
      . . "My Type","My Name","n",true, false...
      . )

      . obj.init({
      . . type: "My Type", name: "My Name", rev: "n", doThis: true, doThat:
      . })

      Has anybody conducted or seen tests on the performance of this json
      method vs regular calls.


      . Cleaner calling code
      . Flexible calling API
      . Somewhat cleaner callee code from visually implied namespace (j.arg1)
      . Tightened API calls:
      . . obj.myMethod = function Obj_myMethod(j){// (singleton)
      . . . . if(!isJSON(j)){debugErr("j must be a JSON")}
      . . }
      . JSON variable can be easily passed around

      . Overall size of the calling code is a little larger
      . Hit on interpreter performance to parse json
      . Null value parameter assertions require additional code


      (dupe post from comp.lang.javascript ... just discovered json group
      today :)
    • Show all 4 messages in this topic