|
> From: Barbara Morris > > You're right; both scenarios do involve some level of stupidity or maybe > naivete. But even the best programmers are careless sometimes. Easy > detection of programmer carelessness and limiting the effects of > programmer carelessness are at least as important as small differences > in execution speed, imho. > > I agree that the pointer technique can be safe if used properly. But I > don't think it's the best technique to recommend to others. I think there needs to be a common sense threshhold at which you make these decisions. My C implementation of handles was done in a shop where I hired all the programmers and I set the standards. If I were again creating methods to be used internally by my own development staff and I was in control of the programming standards, then I would have no problem with returning a pointer, especially a specifically cast void pointer, which cannot, by definition, be used for anything. The debugging aspect alone of having a real pointer far outweighs the side effects. If, however, I were letting these APIs loose on the world, I would definitely take your cautions to heart and would use a handle approach similar to what you suggested, with perhaps the ability to materialize a structure along the lines of many of the IBM APIs. Not only does it protect the application programmer, but it protects my internals from possible malicious attacks. Again, I think it's a matter of common sense. Our difference may come from our audiences. My primary background is in software development shops where our internals were not made public - it was much easier, and in fact often required, for me to make decisions in favor of speed over programmer protection. On the other hand, when your primary focus is writing APIs for public consumption, then I'd think your focus should definitely be on protecting against programmer mistakes. Anyway, it's interesting food for thought. Your words will definitely come up again during parts of my product design. Thank you for your reasoned and lucid response. Joe
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.