in reply to Re (tilly) 1: Complexity of API argument passing
in thread Complexity of API argument passing

Would it be unreasonable to offer both approaches, the individual functions as well as the 'do-all' approach?

Specifically, in my case, I will be adding data to the internatl structure by a function "add_data_point", which is explicit in what it takes such that it could be prototyped. ($$;$% for example). I could then define various functions "add_data_from_TYPE", TYPE being replaced by what method of data storage I would expect there (hash of hashes, array of hashes, etc). Each function would call add_data_point repeated to add the data to the internal storage in the appropriate manner. This would provide the consistent interface for the API. Again, these functions could be prototyped without problems. I could then provide one last function "add_data", which would do the checks that I suggest in the root node of this thread, and then call out to the specific "add_data_from_TYPE" calls depending on the type of structure. This provides more of the "intelligent" interface for the API, without adding a lot of extra code.


Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
  • Comment on Re: Re (tilly) 1: Complexity of API argument passing

Replies are listed 'Best First'.
Re (tilly) 3: Complexity of API argument passing
by tilly (Archbishop) on Jul 14, 2001 at 03:09 UTC
    I would wonder why.

    It sounds like a lot of work, and a lot of complexity. It makes extending your interface later much harder. It makes it harder to offer a good error check. This "accepts anything" function is going to be much harder to explain. And it introduces a significant point of confusion for people trying to understand how to use your module.

    I simply don't see that what you are adding is valuable. It wouldn't be for me. I really prefer to have several simple ideas that fit together really well than a monolithic idea that tries to solve all of my problems.