File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Comparator- do it looks like problem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Comparator- do it looks like problem?" Watch "Comparator- do it looks like problem?" New topic
Author

Comparator- do it looks like problem?

Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 845
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


SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 845
Any advice..
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19790
    
  20

http://faq.javaranch.com/java/PatienceIsAVirtue


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Piyush Porwal
Ranch Hand

Joined: Apr 09, 2008
Posts: 30
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.


-Piyush Porwal (Junk box)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Comparator- do it looks like problem?