News for hackers. Stuff that matters.
Re:Code Smells: Iteration by chairmanwow on Wednesday August 23, 2017 @12:46PM (#15083005)
Wouldn't this name change be immediately caught by the compiler?
Re:Code Smells: Iteration by wereHamster on Wednesday August 23, 2017 @12:55PM (#15083092)
If you have one, yes.

But I meant when you change the definition of that binding (the right-hand side of the equal sign).

Re:Code Smells: Iteration by dankent on Wednesday August 23, 2017 @12:53PM (#15083079)
I assume wereHamster is referring to the value of the constant being changed, rather than the name.
Re:Code Smells: Iteration by Jach on Wednesday August 23, 2017 @02:53PM (#15084099)
This whole potential problem is one of the reasons the particular example isn't that great. It's overhyped in Java-land where some people treat naked strings like lepers but in places like Clojure-land you'd get a lot of people saying "Just use a keyword" for both places. The keyword's name is its value. It's immutable. An IDE should be able to find all uses of it, or there's always 'ag'. If you really want that coupling behavior, change the interface of the thing you're calling to require conformance to a schema. The simplest way in Java is probably just by taking an enum instead of a string, but there are richer ways (especially outside of Java) worth looking into if you're needing a string value eventually in the implementation since you'll run into the other Java-ism of making a complicated enum class instead of just using enums like keywords with their string value being their actual name value.
Re:Code Smells: Iteration by koolba on Wednesday August 23, 2017 @01:04PM (#15083188)
I'd bet dollars to donuts the situations where you want it to change outnumber the ones where you don't by more than 10:1.