The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
Remimds me of the code generated by a compiler I once knew:
This was in the days of the superminis, very much CISC. This machine (called ND-500) had a "LoadIndex [register] [indexvalue] [min] [max]" instruction: If the value at [indexvalue] was not between [min] and [max], a exception was generated.
This compiler could (optionally) verify all array indexing, using this instruction, but not quite in the straightforward way that you might think. A disassembly showed something like this
LOAD R4, indexvalue
COMP R4, min
COMP R4, max
% everything is OK, go ahead
LOADINDEX R4, R4, 0, -1 % no legal range, will unconditionally generate exception
Generating six instructions to replace a single one can be meaningful, but hardly when one of the six is the instruction you want to replace... I was working in the company making both the CPU and the compiler, so I went to the compiler guy for an explanation. He insisted that since index check was an option, it should not change any code generated, only add code: The index check is like a debugging aid that you might turn off in a production build, and the production version should be exactly the code you debugged, minus the debug features. With the option off, the first instruciton (LOAD R4, indexvalue) was generated. Turn it on, and you get the five additional instructions.
Needless to say: Even though his argument sort of sounds plausible, I strongly disagreed with him. First, index checking is not a debug feature; you keep it on in the production version. Second: Given an option set, the compiler should be free to the best code for that selection of options, ignoring other option sets (think of optimization options!)
After much arguing, he agreed to rather generate
LOAD R4, indexvalue
LOADINDEX R4, R4, min, max
... two instructions is better than six. But he stuck to his principles: I never got him to generate a singel LOADINDEX.
The code is written by very senior developer on my team with huge years of experience in c#
There's the problem right there -- they're not used to thinking of base, simple types as classes. Ask them what they think an int? is, and they'll probably tell you it's a pointer to an int. Pointers aren't classes that can have functions.
you are probably right, once i was having code review meeting with that dev and i was asked to replace var keyword with that particular type name, as according to him, it will degrade performance, i then corrected him and gave reference to a post which explained it is just implicit variable that infers the type and nothing else.
My all-time favourite was from a mid-level programmer of ours who wanted to pass a form field value from one web page to the next: something he did all the time... except that in this instance, for some inexplicable reason, he created a table in the database, used Ajax to write the value to it and retrieve a record ID; he then put the record ID into a hidden field on the page, submitted the form, and then, in the next page, used the record ID to retrieve the value from the database and delete the record. Unfortunately, his English wasn't that great... so in response to the question, "What the hell is this supposed to be?" he said, "That mean I do my way. F*** you, Dan!"
The best chance to score at a bar is to cut out a stray. What I mean by that is, single woman rarely come into a bar alone, usually in a herd so to have a chance with one you have to get her away from her friends.
Don't let your mind wander too far.
It's too small to be let out alone.