File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes Refactroing Examples Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Refactroing Examples" Watch "Refactroing Examples" New topic
Author

Refactroing Examples

Rishi Yagnik
Ranch Hand

Joined: Jan 04, 2001
Posts: 84
Hello all
I am a big fan of Frank now my problem is as follows pls help me out
I have downloaded a junit pls do tell me how can i go ahead this is my first of designing

now this method having a 40 lines it is not at all good for OODesign pls do help me
Rishi
(post refactored by jlacar to display code better)
[ August 30, 2002: Message edited by: Junilu Lacar ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Probably the first refactoring we should do is combining declarations and assignments to initializations as that makes subsequent refactorings easier: http://www.refactoring.com/catalog/replaceAssignmentWithInitialization.html
So, what does your code look like after you applied that refactoring? (Please use code tags when posting code.) Can you identify another code smell in it?
[ August 30, 2002: Message edited by: Ilja Preuss ]

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
When your done with that, notice that you're both parsing and processing in the same loop. Consider if using Split Loop would enhance the readability. Usually people can get away with loops that both parse and process, but that methods is indeed looking a bit cluttered.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Refactroing Examples