Lets say there is a method that searches for book authors by book id. What should be passed as a parameter to such method – only book.id (int) or whole book object?
Or another example. In java I need to do some work with current url of the page. What should be passed to such method – only request.getRequestURL() or whole request?
I kind of see benefits from each method but can’t come up with good rule when to use what.
Thanks.
I am not sure if there is a “rule” to what is best, but I most often pass just the paramaters I need into the method. So in your first example I would only pass in the book.id and in your second example I would only pass in the request.getRequestURL().
I try to avoid passing in more than I need.