Someone proposed to me this pattern which I have never heard of before and can’t find any information on it.
The basic idea is, when building a library for other developers to use; if the developer includes my library along with a 3rd party library the behavior of the API calls to my library changes.
An example:
- I have a library/API for inserting, getting, updating, deleting on a database.
- Developer includes a 3rd party database encryption library.
- My library/API changes to require a “unencrypt(password)” call to be made before inserting, getting, updating, deleting.
Is this a safe practice? Is there anything else out there like it? What advantages and disadvantages are there to this pattern?
0
Essentially what you are saying is that you’d like to design your library to have a dependency on a third-party library, and fall back to some default behavior if that third-party library is not available.
I think this is perfectly acceptable as long as it is well-documented.
If you are asking whether it is acceptable for an API call to do two entirely different things, I would say no. The meaning of the API call should not change depending on the presence of another library.
4