Reusing Java Libraries

In software development, we all use libraries by software vendors. Consider four functions in class A: x, y, g. I just want my development team not to use the x function. Therefore, instead of telling them not to use, I found an idea. Inherit the class and override all functions, and unsupportedmethod exception is thrown for function x, and for the rest I call super methods. There I also found a problem, developers can directly use the base class A, how to avoid the direct use of class A. I found similar functionality in OSGi, lib packages can be introduced and then not exported, and so on. Is there any way to achieve this - java?

+5
source share
4 answers

I believe that for these reasons, code reviews exist. Consider a situation where you cannot edit the source of a third party, what would you do? Like Siddhart, he subclasses it and throws a meaningful exception and documents it with clear reasons. If someone uses the base class even after this, basically it may not be due to ignorance, but it may be out of curiosity. Such a thing can be evaluated personally and for training, but for the project, the developer must follow the recommendations.

+2
source

I think just telling your developers what to do is preferable to a complex software solution. Sometimes a simple thing is better.

, , , , Spring. , , .

+1

. , . . , jdbc wraper, .

0

, , , , .. Java Maven Enforcer, checkstyle PMD.

, . . , , " " ; , PMD, .

0

All Articles