Programming Terminology – What is Considered Third Party Code?

designobject-orientedprogramming-languagesterminologyunit testing

Inspired by this question Using third-party libraries – always use a wrapper?
I wanted to know what people actually consider as third-party libraries.

Example from PHP:
If I'm building an application using Zend framework, should I treat Zend framework libraries as third party code?

Example from C#:
If I'm building a desktop application, should I treat all .Net classes as third party code?

Example from Java:
Should I treat all libraries in the JDK as third party libraries?

Some people say that if a library is stable and won't change often then one doesn't need to wrap it. However I fail to see how one would test a class that depends on a third party code without wrapping it.

Best Answer

Your examples are all third-party code, but you should not write wrappers for them. They are large, mature projects with stable and well-planned APIs.

The need for wrappers is to provide a layer of abstraction between your code and the library. You only need this abstraction when you discover that a library doesn't provide good APIs for the specific thing you're doing. Then you might create the wrapper to simplify your own code, and hide the fact that the API calls are awkward.

Your code will be testable if you use dependency injection. In your unit tests you can swap out the library dependency with a mock object, allowing you to isolate your code under test.