Search code examples
javanaming

package naming in case of reusing library class


Let's assume I am using a library class like library-package.LibraryClass.

package library.package;
class LibraryClass {}

I looked into its implementation and for my application purposes I want to modify that class a little and then use. My application has package application-package.

package application.package;
class ApplicationClass {}

How should I name the package where that class LibraryClass should be stored? Should I reuse in my project library-package or should I use scheme application-package.library-package because I recall I ran into such scheme too.

First one

src\main\java\application\package
src\main\java\library\package

Second one

package application.package.library.package;
class LibraryClass {}

Solution

  • I think this probably boils down to opinions, but let us extract the facts at hand:

    • from a technical point of view, it shouldn't make any difference (unless you run into conflicts, because some other part of that library expects all classes to exist within those library packages)
    • beyond that, you are creating something (which happens to be based on some 3rd party library)

    Coming from there: the "natural" solution would be to express "you are the owner of this class" by using that application.package.library.package naming convention.