File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refactroing Examples

 
Rishi Yagnik
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
David Weitzman
Ranch Hand
Posts: 1365
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic