Edit -- I have no limited my question down to a more specific question.

Is there an argument not to wrap a 3rd party user input validation library?

To me there are a few strong arguments to do so.

1) By writing a wrapper it makes it easy for me to extend or inject additional implementation into the library.

2) If I change the dependency, say I have found a better input validation library, I can swap them out relatively painlessly, I just need to update my wrapper.

3) If the dependency updates it is easy to migrate.

4) It makes testing easier

  • I think focusing this on one particular kind of 3rd party dependency would make this a great question. For instance should you write a wrapper for a user input validation library? Probably not. Should you write a wrapper for uploading images to Amazon's AWS cloud service? If you want to quickly switch cloud providers because one is offering you a $500,000 savings? You bet you should. Mar 22, 2020 at 18:02
  • 2
    Does this answer your question? Using third-party libraries - always use a wrapper? Mar 22, 2020 at 18:07
  • OK, my initial question really was intended to be so broad exactly because there is seemingly no one-size-fits-all answer and that was the interest to me. But you suggest that a user input validation library should probably not be wrapped, while I would definitely be inclined to wrap it. I will update my question. Mar 22, 2020 at 18:08
  • In answer to whether that question answers my question, I feel not, there the discussion seems to all in favour of wrappers and more geared to explaining their many advantages. In practice I do not find things are wrapped that often, so it must be that it's not the all singing all dancing solution to all problems. Mar 22, 2020 at 18:11

1 Answer 1


Do it when you’re done experimenting with your needs.

It’s easy to become enamored with a new toy and buy into it’s way of doing things. That’s fine when you’re learning what it’s good for. But eventually you should get to a point where you can see what real needs you have that this thing can provide.

Formalize that relationship in some way that makes clear what needs to be replaced if the 3rd party software has to be removed. That can be done with an interface, an adapter, or a wrapper.

The advantage is this will clearly show future developers that rather than needing to recreate an entire library they only need these few features.

Then they can either implement those few features themselves or they can wire the wrapper up to some other 3rd party library.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.