Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Is it reasonable to eliminate functionality that you're wrapping?by stevieb (Canon) |
on Mar 03, 2017 at 02:35 UTC ( [id://1183498]=perlquestion: print w/replies, xml ) | Need Help?? |
stevieb has asked for the wisdom of the Perl Monks concerning the following question: This is a question of opinion on API usage, not a direct coding question. I've got an API. This API calls underlying C functions. The author of the C library changed his mind to remove safety checks on a particular routine (eg: setup()), so that it no longer checks whether that function has been called or not. In some of my Perl code, I do some due diligence and ensure we call the proper setup() in the right order, and ensure it is only called once. The reason for the checks in the C code, is if an inexperienced or lazy coder calls the function too many times, it can result in a situation where no more system-wide file handles will be available, essentially, crashing the system. There are five such setup routines. I'll depict them like this:
Now, in my Perl code, I magically track any time a sub module runs to ensure that an already existing setup hasn't been executed. With the C restriction lifted, I *still* want to do this, but I want to drop support for all but the most-used routine (aka pin mapping scheme), which is GPIO. In my distribution, I have removed all references for the routines I don't want used anymore in the documentation, but left them in code just in case (there's no legacy issue here, as nobody was really using my code before I made that decision). My question, is whether from your perspective you'd keep true to the underlying C libraries you're wrapping, or sacrifice some convenience to some users, and make things much, much easier for yourself maintainability wise going forward. Because this is Perlmonks, here's some code. This is some init code that actually aids in deciding whether a setup routine has been called or not. Yes, there are a lot of if/else stuff, but because I knew I'd approach what I'm asking here someday, I wanted it nice and open and free-flowing.
Removing all of the setup routines less the one I want would make it *tremendously* easier to support going forward maintenance-wise, as well as making things a lot more flexible in the long run. I can still perform the safety check, but a lot of code could be removed, and the checks would become much less aggressive and to put it bluntly, less fraught with potential holes. I'm thinking remove. What do you think... maintainability or adhering to the underlying API?
Back to
Seekers of Perl Wisdom
|
|