• Post Reply Bookmark Topic Watch Topic
  • New Topic

Code reuse  RSS feed

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a general discussion rather than a Question.

What does Code reuse actually mean? Does it mean I write a piece of code say JDBC library and reuse it number of times in different applications by just passing it different parameters, or having a class and using it number of times in the same application to create a number of objects???
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both are included.
You write small methods and use them again and again. If you look at the way to keep interrogating a Scanner until an int is received, you quickly realise that can be put into a (static) method in a utility class, which you are reusing rather than rewriting.

Remember once you have used code and tested it and confirmed it is working, you don't need to test it again. Look at this Joel Spolsky article, which is about something similar.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!