File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Trying to get rid of redundancy? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Trying to get rid of redundancy?" Watch "Trying to get rid of redundancy?" New topic
Author

Trying to get rid of redundancy?

Ashley Kin
Ranch Hand

Joined: Oct 18, 2011
Posts: 36
Hi, I'm trying to get rid of redundance in this program by factoring? Thank you for any help! (Sorry, I'm not sure how to use clipboard)


Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7696
    
  20

Ashley Kin wrote:Hi, I'm trying to get rid of redundance in this program by factoring?

Well, the usual way is to put repeated code into a method and call it instead. And it seems like you have 2 big blocks of repeated code. You might want to think about parameter(s) for that method as well, so that it's self-contained.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
another way is not to post the same question in two forums. You've got this same one in "Java in General".

rc
Harsha Smith
Ranch Hand

Joined: Jul 18, 2011
Posts: 287

Ralph Cook wrote:another way is not to post the same question in two forums. You've got this same one in "Java in General".

rc


good sense of humor!
Sven Eriksson
Greenhorn

Joined: Oct 20, 2011
Posts: 1
Hi Ashley

Easiest would be something like this:



Hopefully that might help some, but you could also write it in another method and call to it
Remember, everyone codes differently...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Trying to get rid of redundancy?