|
Well, the whole thing could be reduced to
bool isOffset = reader["foo"].ToString().ToUpper().Trim() == "BAR";
Why couldn't the programmer see that? Why didn't someone in the 2+ years that this code has been in production fix it?
Marc
|
|
|
|
|
Very true! I was just pointing out that new bool() isn't as crazy as it looks at first glance
|
|
|
|
|
Jon McKee wrote: I was just pointing out that new bool() isn't as crazy as it looks at first glance
Quite so. I don't usually even think about bool being shorthand for System.Boolean, and it's good to be reminded of the deeper nuances of the language.
Marc
|
|
|
|
|
Marc Clifton wrote: Well, the whole thing could be reduced to
I guess it can if reader["foo"] can never return null.
|
|
|
|
|
So, just for my own understanding then, something like this would be better then correct? ...
bool isOffset = (reader["foo"]?.ToString().ToUpper().Trim() == "BAR") ?? false;
Jeremy Falcon
|
|
|
|
|
Marc Clifton wrote: Why couldn't the programmer see that? Why didn't someone in the 2+ years that this code has been in production fix it?
I have always predicted that this type would show up on the scene sooner or later and, by now, have seen them in action often enough.
They actually do as they were told and avoided memory management at all cost. That is why they have no understanding what value types and reference types are all about, nor do they have any idea how value types are an illusion created by the compiler to spare us having to wrestle with references and check for null for every variable. To them these things make no sense and appear to be some random and arcane rules which have been inherited from languages of the past.
The same goes for logical operators. I have given up on trying to help the kids when they can't get it done. They think that's more of this arcane ancient stuff that nobody needs to know anymore. Letting them figure it out themselves is the only way to convince them otherwise. So be it.
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
FWIW while bool is "sort of a struct", like all primitive types instances of it are "created" (without any ctors being called) by MSIL instructions, eg true is created by
ldc.i4.1
And new bool() literally is (not just sort of metaphysically/hypothetically according to an AS-IF rule but the literal compiler output)
ldc.i4.0
I guess the moral of this story is that bool is int
|
|
|
|
|
Interesting. Looking at the CLI Specification[^] I.8.2.2 on page 46 that makes sense. Under all the abstraction it's an integer type.
|
|
|
|
|
Well, look: a variable must be initialized before it can be used. Now just imagine: somehow a third possibility comes into existence which is not covered by that if ... else - now you'll run into an error when you access isOffset because it was not initialized.
|
|
|
|
|
So you want
if (...)
...
else
...
maybe
...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Reminds me of the fuzzy logic that was so popular in the beginning of the nineties.
|
|
|
|
|
Do you have a keyboard?
Hit CTRL+A/Del and save us!
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
bool IsOffSet = new bool { improved };
New version: WinHeist Version 2.2.2 Beta I told my psychiatrist that I was hearing voices in my head. He said you don't have a psychiatrist!
|
|
|
|
|
Disclaimer: maybe your outsourcing experience is better, but I've never personally seen it. It also speaks volumes of the lack of code reviews by a major company before this stuff went into product. Is the expression "well, it works" sufficient justification?
For example (reduced to the essential):
public string getRecordToBeProceed()
{
if previuosXML()
{
RecordToBeProceed = "1";
}
}
Typos and outright errors: "RecordToBeProceed" should be "RecordToBeProcessed"
if (getRecordToBeProceed()) ...
And you just gotta love (or not) the string "0" and "1" used to represent a boolean.
Marc
|
|
|
|
|
On the bright side, they're (mostly) English words
Ah, I see you have the machine that goes ping. This is my favorite. You see we lease it back from the company we sold it to and that way it comes under the monthly current budget and not the capital account.
modified 31-Aug-21 21:01pm.
|
|
|
|
|
|
We dream of code that good in our team
Ah, I see you have the machine that goes ping. This is my favorite. You see we lease it back from the company we sold it to and that way it comes under the monthly current budget and not the capital account.
modified 31-Aug-21 21:01pm.
|
|
|
|
|
Quote: Is the expression "well, it works" sufficient justification?
A friend and co-worker of mine refers to this type of thinking as, "passive mediocrity".
"...JavaScript could teach Dyson how to suck." -- Nagy Vilmos
|
|
|
|
|
Z.C.M. wrote: A friend and co-worker of mine refers to this type of thinking as, "passive mediocrity". I shall shamelessly steal that.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Ouch. My eyes are bleeding and begging for mercy after looking at that "code".
|
|
|
|
|
Marc Clifton wrote: I've never personally seen it Yes you have!
|
|
|
|
|
Sander Rossel wrote: Yes you have!
Ha! Nothing personal, and I was trying to be politically, if not correct, at least sensitive, to how I really wanted to title the post "The joys of outsourcing to India", which is where this code comes from. I think I assumed people would assume I was talking about India.
Marc
|
|
|
|
|
If you thought India was bad try Romania!
I still get mad thinking about it
Actually, I still have a t-shirt with the face of their lead dev and the words he said to me in an email (after I completely burned the garbage they delivered to the ground) "You prefer to wait and hit after, thanks we'll remember!" (seriously, no joke)
I got that t-shirt when I left that company (and the outsourcing was one of the reasons I left)
|
|
|
|
|
Sander Rossel wrote: You prefer to wait and hit after
That's a good one.
Marc
|
|
|
|
|
I don't need outsourcing for that...
|
|
|
|