This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, I would like the expert opinion over here on making this piece of code less smelly.
It is working code so while loop exits properly on some condition It is basically processing a screen line by line and populating objects based on the information on the current line.The methods on the summaryPageDetails return false if the line does not match the regular expression
[EJFH: Added CODE tags to preserve formatting ] [ November 29, 2005: Message edited by: Ernest Friedman-Hill ]
If all the checks to see if a match is found are performed on the summaryPageDetails object, then I'd move the entire contents of the loop into a method on that class.
Then, make each method into a class of its own with a common method call, like public boolean doesRowMatch(...), with whatever arguments are appropriate. Loop through a collection of instances of these classes, calling doesRowMatch() on each instance until one of them matches. You can even make these processor into inner classes so they have access to common data of the caller.
Does that make sense?
Rick [ November 29, 2005: Message edited by: Rick Goldstein ]
Joined: Jul 21, 2004
Rick, Thanks for the reply I was kind of thinking along those lines but your explanation made it very clear. It will need a little more work though. SummaryPageDetails is already an inner class! if the file becomes huge i'll do some more surgery Santosh