I am re-learning Java after having an affair with PHP for some years, and I have a question about a convention used in PHP, and how I would accomplish a similar goal in Java...
PHP
function getReport( $options = array() ) {
}
in the above function you would be passing in an optional associative array of options that may look like this
Array(
from => "20110325",
to => "20110413",
subject_id => "2432",
...etc...
);
And if there is no argument passed, it processes fine with no options.
Below is my attempt to form the same function in java, being as it is Strongly typed (which is quite refreshing in some instances) I am having trouble building in the same flexibility. I've considered using a Dictionary
but not sure how "best practice" that would be.
public TimeReport getTimeReport(Date from, Date to, int subjectId, int toDoItemId, int filterProjectId, int filterCompanyId) {
}
To call this with one/two/none options it gets pretty ugly with the arguments being...
getTimeReport(null,null,null,234,null,null);