7 ms·
It's not clear from your post (and you don't have to make it clear, of course) whether you're getting fired from your current company or not. Merely failing on
by sokoloff 6y ago
It's not clear from your post (and you don't have to make it clear, of course) whether you're getting fired from your current company or not.
Merely failing one task won't get you fired and if you have the self-awareness demonstrated above to realize that you haven't yet learned what you need to become senior, gives you a clear path (and one that won't even be that hard if you've been selling and making software for 10 years).
Making software in a team is a somewhat different skill and you just need to learn it.
I contrast your case (understanding the issues) with a code review I did around 20 years ago where someone had hardcoded the value 17 in a bunch of places in a mixed c / c++ codebase. I suggested he use a #define for the magic/hardcoded values.
I kid you not, his resubmission contained:
#define SEVENTEEN 17
and the points of use all now said SEVENTEEN. (At least the instances of 34 were replaced with SEVENTEEN * 2.)
That programmer wasn't going to make senior. You will. If you're getting code reviews that are pointing out these issues at your current place, stay there and learn. 6 months from now, you'll look back at your thread here and realize just how much you've progressed with the live mentoring in a team and the spaced-repetition of go away and code, get review, improve it, get review, etc.
- arethuza 6y agoI remember one from Java ~20 years ago: public final static string HTTP = "http"; public final static string COLON = ":"; public final static string SLASH = "/"; public final static string WWW = "www"; with code like string url = HTTP + COLON + SLASH + SLASH + WWW .... Ignore any Java issues - not used it much in ~15 years. Edit: I asked the developer who had written this what it was achieving and he said it was best practise ;-)
- arthur_sav 6y agoWell, 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 ago
- 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 :)
- stagger87 6y agoWait, what was wrong with the #define solution? Just the name of the macro? Didn't he do what you wanted?
- sokoloff 6y agoThe 17 was a scaling factor for a graphics transformation (and sometimes was doubled to 34). Let's imagine that we later decide we want to make a change and have it be a little bigger. Do we change it to: #define SEVENTEEN 23 Instead, if it was: #define MENU_SCALING_FACTOR 17 then such a change would be sensible (which was the intention). I admit to having some sliver of culpability here (though the verbal explanation of why we'd prefer to pull the hard-coded numbers out of being sprinkled all over the codebase I assumed would have sufficed). This seemed to border on /r/MaliciousCompliance, but I know he was actually trying his best (and was pre-reddit, of course).
- stagger87 6y agoThanks for the clarification. I guess the tools you had available at that time would affect the severity of this. Nowadays, with the ability to refactor a macro name in a few seconds, I wouldn't necessarily agree that a developer that used a silly name would "never make it to a senior developer". Fuck, I'm "senior" and I definitely use worse variable names on a regular basis.
- sokoloff 6y agoI think I disagree strongly on the first point. If SEVENTEEN is used instead of MENU_SCALING_FACTOR and ARBITRARY_OTHER_THING (two semantically different things both happening to be 17), no refactoring tool (that I’m aware of) is going to be able to tease apart just the former use and amend it to 23, leaving ARBITRARY_OTHER_THING as 17. const int declarationAdoptedYear = SEVENTEEN * HUNDRED + THIRTY_EIGHT * TWO;
- stagger87 6y agoI use QtCreator and it would be able to do this. If I had #define SEVENTEEN 17 and another macro #define OTHER_THING 17 I could simply refactor SEVENTEEN to #define MY_NEW_NAME 17 which would change all occurrences of SEVENTEEN to MY_NEW_NAME, and then I would just change the value of that macro. #define MY_NEW_NAME 23