Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Flaggers, this isn't really on topic for Code Review, and it's perfectly fine here. – Yannis Mar 30 '12 at 13:40
up vote 3 down vote accepted

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.

share|improve this answer
Yeah. I would go with the dot syntax. It's more intuitive. – kadaj Mar 30 '12 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.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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