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

What's the good practice advantage over just using "http://www"?

If we later change over to use https, it's not like I'd think

  public final static string HTTP = "https";
was any kind of improvement.


Yes, I'm struggling to thing why you'd ever want to construct URLs that way - I'd stick them in configuration with parameters if required.

Edit: Glad someone noticed it was "http" - which is one of the details I do remember correctly.


Autocomplete and composition purposes, i do it mostly with commonly used strings. Less likely to miss-type something.

Some devs are such stuck-ups smh


You could use refactoring tools in your IDE to rename all usages of HTTP to HTTPS.


Which will break other code where someone wrote:

  // Ensure all outgoing URLs are https:
  URL = URL.Replace(HTTP, HTTPS);


Technically it would still work though?

  Replace(HTTPS, HTTPS)


It depends on what you mean by "still work", but in general I'd say "No, it won't work."

If URL starts as "http://www.google.com/", and I expect that will get re-written to an https URL here, the code will compile and run without throwing any errors, but won't accomplish the intent of why that line of code was written and was doing previously. (URL will still contain "http://www.google.com/")




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

Search: