Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handing a method it's own output

 
Rian Nolan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

If I have (for instance) a method that takes an int and a String:
...what is the JAVA way of handing the output of the method back in to the method multiple times?

I figure I could nest it:

...but I'm not sure that that feels like the way it should be done.

Is there a "standard" way?

Full disclosure - I may just be trying to save myself from a nitpick here ;-)

Cheers,
Brian
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a gazillion (scientifically speaking) ways to skin a cat, but in general you'll probably do well with something like this:



The second one is confusing, has the potential for bugs, (and, pardon me for mentioning it) really ugly
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So to nitpick your snippet...



Please check the style guide for the correct naming of identifiers...

It could be written a little more succinctly (arbitrary values chosen instead of foo and bar).



 
Rian Nolan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...so I have saved myself a private nitpick by undergoing a public one?
Way to go - me.

Thanks for that Katrina - it DOES look and feel more readable.
Ever onward with Java-4b (Say)...
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, but it saved you an extra round trip on Say 4b... so it must have been worth it!
 
Rian Nolan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WELL worth it Katrina

Thanks a millon!
Brian
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic