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

Comparator- do it looks like problem?

 
Amandeep Singh
Ranch Hand
Posts: 850
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this was my original comparator. And it is working.


As my requirements came in, what i did is added a new BOLD code as shown below.

Is it a right thing to do or better i should create a new Comparator ? My old comparator code is for Double value's and my new code added
is for String. Please i don't want to modify the existing code.



this is the new code i added above. it will return from here only when condition comes for my code
 
Amandeep Singh
Ranch Hand
Posts: 850
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any advice..
 
Rob Spoor
Sheriff
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://faq.javaranch.com/java/PatienceIsAVirtue
 
Piyush Porwal
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it a right thing to do or better i should create a new Comparator ? My old comparator code is for Double value's and my new code added
is for String.


Generally speaking, you are free to alter your comparison approach any time. So this should not be an issue. But you may still want to check the client of this comparator (specially if they have access to this code or if the name of the class says something) to confirm that they are not making any assumption based on your current implementation.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic