Should private helper methods be static if they can be static

Let’s say I have a class designed to be instantiated. I have several private “helper” methods inside the class that do not require access to any of the class members, and operate solely on their arguments, returning a result.

public class Example {
   private Something member;

   public double compute() {
       double total = 0;
       total += computeOne(member);
       total += computeMore(member);
       return total;         
   }

   private double computeOne(Something arg) { ... }
   private double computeMore(Something arg) {... } 
} 

Is there any particular reason to specify computeOne and computeMore as static methods – or any particular reason not to?

It is certainly easiest to leave them as non-static, even though they could certainly be static without causing any problems.

21 Answers
21

Leave a Comment