I have wrote a small method in a program to do one thing my method looks like this:

public static void removeExpiredAssignments(Module module){

So the method is called like:


When the desired operation could be done by saying:


Which is easy to understand from the code point of view?

  • Flaggers, this isn't really on topic for Code Review, and it's perfectly fine here.
    – yannis
    Mar 30, 2012 at 13:40

3 Answers 3


It depends what you're trying to do. Calling the method on the module directly implies that the module is required and directly effected by the action. Calling the method that takes in a module implies that the module may or may not be needed in order to carry out the action, and that it may or may not directly effect the state of the module.

  • Yeah. I would go with the dot syntax. It's more intuitive.
    – user4626
    Mar 30, 2012 at 6:36

This ties in with Jeremy's answer, but I'd say it's a question of whose responsibility it is to execute the method. Is the module where the knowledge of how to perform this belongs? If so, it should be the module that executes the method on itself. If the knowledge of how to do this belongs elsewhere, the method should be on that other object/class and take the module as its argument.


Java still feels alien to me but I would expect to find the module.functionCall(); syntax; it really is "the java way". I was brought up in C (almost 20 years ago) and the function declaration feels old fashioned even to me, so that's saying something.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.