• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Is there a way in netbeans to show which methods etc are never used?

I think i may have a few redundant setters/getters and other stuff, ive noticed netbeans will warn me if a variable/value is never used, is there any way to show which methods are not called during a run of a program?

I know this could lead to me deleting something valuable because if a method isnt called that dosent mean it will never be called but i can at least look at it and see what if anything it actually does 🙂
 
Never used is a surprisingly hard problem. A method might be reachable in a variety of ways and determining true reachability is fuzzy in a lot of cases. All this analysis can be made worse by the use of reflection which means that pretty much any method could get called without any direct or obvious possible indirection.

Take for example a method that calls a method 'aMethod' on an interface 'IFace'. If I have two implementations of IFace both with an aMethod, but nowhere in the code do I see either implementation created does that mean that aMethod is or is not called? One of the two implementations is extremely likely to get called if the code calling onto IFace is ever called but even this simple example isn't possible to reason about because its determined at runtime.

I have been working on a solution to this problem for a while and I am likely to release some software that helps sometime this year, which is a bit cleverer than just statically called.
 
If you're worried about dead code just make sure you use private functions judiciously. If a function is public in a language that supports dynamic binding either use it or lose it.
 
If the method is private, then netbeans will let you know if it is never used. However, public methods are not checked for usage for the reasons BrightCandle has pointed out.
 
Back
Top