IMO if you agree that "/" works in all relevant cases, then using a new constant doesn't make any more sense than saying a comma separated list should be build using a "Punctuation.COMMA" constant. Or my name should start with a "Letter.P" constant.
Just my opinion, Letter.P + Letter.H + Letter.I + Letter.L On Wed, Dec 29, 2010 at 4:08 PM, Rob Ross <rob.r...@gmail.com> wrote: > I think you'd want to use "File.separator" instead of hard coding "/" for the > same reasons constants are better than hard-coded values in general. > > It captures the semantic context of the constant value, for one thing. It's > clear that you intend to use a file separator character in that context. You > may be using "/" in your source code for other purposes, perhaps as a > separator in an XPATH query, or for some of the many other uses of that > character. > > Even though it may seem more verbose, it increases maintainability. It's the > textbook case of self-documenting code. It's also a formal refactoring > technique labeled "introduce explaining variable." > > If I were doing a code review with you, I'd strongly encourage you to keep > File.separator instead of "/". > > > > Rob > > On Dec 29, 2010, at 2:54 PM, Christian Catchpole wrote: > >> Yeah, that's my experience. You might need it if you are building >> paths for display or whatever. There might be some other weird >> conditions where you might need it (edit or building existing paths). >> But for something simple like new File("./path/file"); I can't see why >> you would need the File.separator >> >> On Dec 30, 3:30 am, phil swenson <phil.swen...@gmail.com> wrote: >>> I find code that uses the "File.separator" field irritating. It makes >>> the code uglier and best I can tell "/" works everywhere, including >>> windows. Does anyone know if there is a reason to use File.separator >>> instead of just "/"? My guess is unless you are writing java code >>> that writes to a .bat file or something along those lines, "/" is >>> fine. Right? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "The Java Posse" group. >> To post to this group, send email to javapo...@googlegroups.com. >> To unsubscribe from this group, send email to >> javaposse+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/javaposse?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "The Java Posse" group. > To post to this group, send email to javapo...@googlegroups.com. > To unsubscribe from this group, send email to > javaposse+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/javaposse?hl=en. > > -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to javapo...@googlegroups.com. To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.