4 ms·
Well, actually... it could be a good practice, if the values are used in multiple places.
by arthur_sav 6y ago
Well, actually... it could be a good practice, if the values are used in multiple places.
- sokoloff 6y agoWhat's the good practice advantage over just using "http://www 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.
- arethuza 6y agoYes, 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.
- tppiotrowski 6y agoYou could use refactoring tools in your IDE to rename all usages of HTTP to HTTPS.
- sokoloff 6y agoWhich will break other code where someone wrote: // Ensure all outgoing URLs are https: URL = URL.Replace(HTTP, HTTPS);
- tppiotrowski 6y agoTechnically it would still work though? Replace(HTTPS, HTTPS)
- sokoloff 6y agoIt 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/ 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/ http://www.google.com/")
- arthur_sav 6y agoAutocomplete and composition purposes, i do it mostly with commonly used strings. Less likely to miss-type something. Some devs are such stuck-ups smh
- marcandre 6y agoWhat next? `ZERO = 0`, `ONE = 1`, ...?
- arethuza 6y agoPretty sure I've seen that as well (different codebase though) - that kind of thing happens when you have a code style rules that says "No literals in code, always define constants" and people take it literally.
- klibertp 6y agoYou know, it wasn't that long ago when booleans in Python were essentially: True = 1 False = 0
- Izkata 6y agoWasn't there a post here a month or so ago where someone found something like "three = 5" in the linux kernel?
- snapetom 6y agoI had a coworker do this all over a Cold Fusion codebase. He also claimed he used to be a dentist in Mexico, so anywhere he had his name, email sigs, code comments, etc., he would sign add "DDS" after his name. Dude was a trip.
- mLuby 6y agoChurch encoding is mind-bending. ZERO = (f, x) => x ONE = (f, x) => f(x) TWO = (f, x) => f(f(x)) THREE = (f, x) => f(f(f(x))) TRUE = (a, b) => a FALSE = (a, b) => b IF = (p, a, b) => p(a, b) NOT = (p, a, b) => p(b, a) AND = (p, q) => p(q, p) OR = (p, q) => p(p, q)
- dehrmann 6y agoIt buys you nothing, and in the case of WWW, when you're grepping your code base to find everywhere you have "www.oldvendor.com", it fails.
- klibertp 6y agoWould be ok if the variables were named like `PROTOCOL`, `SEPARATOR`, `HOST_PREFIX`. The names shown in GP are... well... a shining example of how naming things is hard, at least :)