Re:From Rails to Clojure, Then to Java, Then Back to Rails
by whack on Wednesday March 21, 2018 @02:25PM
(#16640970)
This might be a stupid question and a tangent, but what does he mean by: "don’t use raw strings as constants"
[ Parent
| on HN ]
Re:From Rails to Clojure, Then to Java, Then Back to Rails
by w4tson on Wednesday March 21, 2018 @04:11PM
(#16641878)
Probably saying something like
public String getDescription() {
return “some constant”;
}
Versus public String getDescription() {
return FOO_DESCRIPTION;
}
it’s a fairly weak example but you get the idea.
Re:From Rails to Clojure, Then to Java, Then Back to Rails
by NegativeLatency on Wednesday March 21, 2018 @04:12PM
(#16641897)
I really can't tell, but if I were to guess it would be the difference between something like
`User.where(thing: 'foo')`
and something like
`Foo = 'foo'; User.where(thing: Foo)`
So you can refactor/find things that use Foo easier than 'foo'. You would probably get editor support for the constant "Foo" and not for the string "foo".