• Post Reply Bookmark Topic Watch Topic
  • New Topic

object/collection modification  RSS feed

 
manish ahuja
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I wanted to hear viewpoints whether this a good practice or not.
There are business methods which modify a object/collection.
The business framework calling method will invoke the above stated methods passing the required object/collection.
Now should there method signature of the business methods be void or should the methods have a return type.
Which is more appropriate in the java sense
-----------
style1) public void modify(Model obj);
style2) public Model modify(Model obj);
-----------

-MA
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this a remote call or a local call?
 
manish ahuja
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its local
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest you go for style 1 i.e.
You can still hold a reference to the "model" and use it when the method call returns.

I have always been of the personal opinion, that whenever you have a return type, the returned object is either a "computed one" are it is returning some value which was encapsulated inside the object.

For me it does not make sense to return back an object which was given to a method for some processing (as in your scenario).

Needless to say, this is my personal opinion and others may have different views.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!