Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This might be a stupid question and a tangent, but what does he mean by: "don’t use raw strings as constants"


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.


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".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: