I have a small Utility library containing some useful utility methods which have been fully unit-tested. At the moment, my library has no external dependencies. I am toying with the idea of adding logging to my classes which might be useful for debugging purposes. But this would mean bundling logging libraries along with my project.
My question is: should I keep my library dependency free? Are there any advantages of doing so?
Dependency on libraries. If a module or mediation module needs to use resources from a library or if a library needs to use resources from another library, you have to open the module or library with the dependency editor and add a dependency on the required library.
Typically, a library is also something that is not executable, but requires the consumption. A dependency, like the earlier answer suggested, is a relationship between two pieces of code. The first code calls out to the second code to either perform an action or return some information.
Dependency management is a technique for identifying, resolving, and patching dependencies in your application's codebase. A dependency manager is a software module that helps integrate external libraries or packages into your larger application stack.
I would add a logging interface that the can be used to abstract the logging. Then the allow users to add logging via this interface. You too should use this interface, and you should supply a 'NullLogger' built into your library that would be used if no other logging is needed.
You can make it easy to not use the NullLogger by asking users to configure a new one, simply by config file or by run time discovery.
Use Java Logging. It's part of JRE/JDK so no external libs are needed.
Check out examples.
There are many advantages of doing so, not the least the ability to run on most any operating system.
One way of keeping your library pretty dependency free, is to require it to initialized prior to use. Then you would in your_lib_init(); function take a function pointer to logging backend. This means, the backend can be rewritten for any platform it might run on.
Also figure out, if you want a library totally free of all library dependencies, or one that depends on the standard class path. If it is pure Java, it will run on J2ME, Android, native compiled Java with GCJ and what not. If it uses class path, it will be portable across all class path implementations, in practice wherever OpenJDK runs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With