Not? Shortcutting logic? Never heard of those!
-
Something I'm adding functionality to: (Anonymized names)
' SNIP: User input is read from a form and validated If thing1set = True And thing2set = True And thing3set = True And thing4set = True Then schalter = True Else schalter = False End If If schalter = False Then Exit Sub End If ' SNIP: User data is being stored
That's VB.NET, btw.
-
Ugh. I hate when people do this. Mark of a junior. I know, I'm dealing with one.
-
Well, it's funny how I'm the most junior developer at the company and had zero experience in VB.NET before I started working there.
Whoops.
-
Not even
If thing1set = false or thing2set = false or thing3set=false or thing4set = false
. Someone hasn't grasped boolean logic properly.Oh holy hell, or even just putting the Exit Sub in the Else statement!
-
Well, it's funny how I'm the most junior developer at the company and had zero experience in VB.NET before I started working there.Whoops.
Some people are junior in the head.
-
Some people are fucked in the head.
FTFY.
I know, I'm dealing with one.
How's it going? Anything storyworthy?
-
How's it going? Anything storyworthy?
Ugh. Don't remind me.
I planned to keep posting updates in the training thread, but he's either blasting away code on his own, or I'm too frustrated with trying to explain node's callbacks to have the energy to whine about it here.
-
7/10 Would front page again.
-
Might even be quite possible, if you take post #3 into account.
You could make it a frontpagey thing and submit it as your third attempt to become a writer~
-
Might even be quite possible, if you take post #3 into account.
You could make it a frontpagey thing and submit it as your third attempt to become a writer~
Tempting... but I'm not quite sure TDWTF is quite my thing for writing purposes. Much as I would like the money, and feeling like I could contribute to this community... I'm not sure I'm right for them.
-
Here, have another example of VB.NET code I encountered today that can be dramatically simplified:
Public Shared Function DeleteLocalLicFile(ByVal filename As String) Dim success As Boolean = False Try File.Delete(filename) success = True Catch ex As Exception success = False End Try Return success End Function
Yes, that function doesn't even have a return type.
-
Like, the stuff I work with has all those generic mini-WTFs that are just ...boring.
Overcomplicated Booleans, typeless functions and parameters, useless functions and so on.
They only get really WTFy if you go to form scope with things like this:
@aliceif said:Well ...We're talking about things like "If you open a Window, choose some things and click save, it saves the default values and not the ones you've chosen". With the relevant controls not being read from, ever, in the code.
Although, I had a really tasty spaghetti do-while loop on my plate today, too.
-
If this is the worst thing they've spawned, you're in pretty good shape.
-
Oh holy hell, or even just putting the Exit Sub in the Else statement!
And violate the Holy One-Return Principle
-
With the rules that I set up for my .NET projects, that wouldn't even compile.
-
-
Be grateful for what you have the contract I am on has "The great pyramids of if".
-
the contract I am on has "The great pyramids of if".
They ban logical connective operators? (I believe that VB.NET has them, and so too do virtually every other language used for more than a few hundred lines of program.)The usual problem comes when you start interleaving
if
and looping; that's when it's probably time to refactor…
-
Bad ideas thread, anyone?
Maybe it's a throwback to VB of old that did not understand what "short cutting" meant such that it would always evaluate both sides of an AND even if left side was false.
-
A previously long lost employee had created this monstrosity. The thing that pisses me off half of it could have been eliminated if they had used some interfaces and predicate functions.
-
-
Lost to the jungles of deepest, darkest WTFistan?
-
Because of VB.NET I have started to pronounce
&&
and||
in C-style languages asAndAlso
andOrElse
.
-
<p dir="ltr">A previously long lost employee had created this monstrosity. The thing that pisses me off half of it could have been eliminated if they had used some interfaces and predicate functions.</p>
Heh, had a guy like that at my last job. Made a ton of WTFs, left the company, got re-hired, I fired up Word.
-
VS should display the
Or
andAnd
keywords with a warning whenOrElse
orAndAlso
would be better (although you have cases like bitwise logic whereOr
is needed).
-
He was on another team for a bit, no idea where now.
-
Because of VB.NET I have started to pronounce && and || in C-style languages as AndAlso and OrElse.
That's a sure sign of Post-VB Stress Disorder. It's not too late to seek help. I was forced to code in VB for the better part of a decade and now live what passes for a normal life among DailyWTFers.
VS should display the Or and And keywords with a warning when OrElse or AndAlso would be better (although you have cases like bitwise logic where Or is needed).
Or they could admit that going for backward compatibility with VB6 (with only partial success) was a WTF and make the keywords work properly.
-
Here, have another example of VB.NET code I encountered today that can be dramatically simplified:
Public Shared Function DeleteLocalLicFile(ByVal filename As String) Dim success As Boolean = False Try File.Delete(filename) success = True Catch ex As Exception success = False End Try Return success End Function
Yes, that function doesn't even have a return type.
That seems like a lot of work to go through to create a function that does absolutely nothing that File.Delete doesn't do other than swallow all exceptions.I can image the thought process: I need a function that deletes a file. I know the base class library has File.Delete, but I need one that has a longer name, seems to have something to do with licensing although it doesn't, and if something goes wrong it withholds any details of what that might be.
-
seems to have something to do with licensing although it doesn't
Maybe that function is used only for deleting license files, and there are other functions for deleting configuration files, executable files, data files, etc. All identical except for the function name, of course.
-
Or they could admit that going for backward compatibility with VB6 (with only partial success) was a WTF and make the keywords work properly.
You say that as if C# doesn't have
|
and&
The language is fine, it's just that developers don't understand how it works.
-
You say that as if C# doesn't have | and &
I don't have a strong opinion on this, but: At the same time, the language should encourage correctness. At least in my coding, Boolean and/or is far more common than bitwise and/or... so why would you give the less common operations the shorter and more natural names?The language is fine, it's just that developers don't understand how it works.
-
I believe it actually has something to do with 'making all comparison operators two characters where possible'
I still occasionally get called out by VS for only putting
if (foo = bar)
instead of using==
. And I think==
is a good thing
-
Because they're still keeping a level of backwards compatibility with Basic, and logical and/or is only more common for comparisons, bitwise and/or is still needed for bitwise values, and there plenty of code out there that use that.
If you changed the bitwise and/or, you break it for people porting code, whereas just adding the logical and/or with a different name breaks nothing.
-
Boolean and/or is far more common than bitwise and/or... so why would you give the less common operations the shorter and more natural names?
We're used to it now, but short-circuit evaluation screws up things like:
if (a() && b())
if
b()
has side effects. I think that's the biggest reason as to why they did non-short-circuiting operators as a default - that's how it used to be back in the days when BASIC roamed the earth.
-
The other side of that is
&
and|
are arithmetic operators (like+
and-
). And their associated assignments,&=
and|=
would be a little more involved to type if they were&&=
and||=
There's also the whole maintaining a similarity with C/C++ thing for C#, where bitwise arithmetic was more common during their hey-day.
-
I don't have a strong opinion on this, but: At the same time, the language should encourage correctness. At least in my coding, Boolean and/or is far more common than bitwise and/or... so why would you give the less common operations the shorter and more natural names?
That, I agree with. People are lazy, and CBA to look up how each behaves.
-
I believe it actually has something to do with 'making all comparison operators two characters where possible'
I still occasionally get called out by VS for only putting
if (foo = bar)
instead of using==
. And I think==
is a good thingI still think it should be
=
for assignment,Class.Equals(a, b)
for comparison.
-
I still think it should be = for assignment, Class.Equals(a, b) for comparison.
No, no, no. *thwaps chubertdev with a value-typed clue-bat* Don't you toss value semantics out the window like that!
-
I saw it suggested somewhere that
:=
should be used for assignment,==
for comparison, and=
should be a syntax error.
-
I saw it suggested somewhere that
:=
should be used for assignment,==
for comparison, and=
should be a syntax error.What about languages that differentiate
==
and===
?Oh wait. That's only loosely typed
-
What about languages that differentiate == and ===?
Oh wait. That's only loosely typed
More than one language has == and ===. In Verilog, some boolean data types can be true, false or a couple different invalid/unknown states. == gives a false value if either operand is invalid/unknown. === will be true if both operands are of the same invalid/unknown value.
-
I know PHP has it, but I assumed TRWTF, so...
-
I saw it suggested somewhere that
:=
should be used for assignment,==
for comparison, and=
should be a syntax error.This is how you get Perl, people!
-
What about languages that differentiate
==
and===
?Oh wait. That's only loosely typed
Yeah, so completely scrap those.
-
In Verilog, [...] === will be true if both operands are of the same invalid/unknown value.
Well now. Coming from a database background, that gives me a bit of a Sheldon-twitch, but I suppose I don't mind the idea.
How would that be useful, considering nulls normally don't equal nulls in database language?
-
Well now. Coming from a database background, that gives me a bit of a Sheldon-twitch, but I suppose I don't mind the idea.
How would that be useful, considering nulls normally don't equal nulls in database language?
The invalid/unknown values in Verilog are a bit more...distinct than SQL's NULL bastardization.
In particular, Z means that a signal is high-impedance/floating/not driven and X means it is in an invalid or 'don't care' logical state.
-
The invalid/unknown values in Verilog are a bit more...distinct than SQL's NULL bastardization.
In particular, Z means that a signal is high-impedance/floating/not driven and X means it is in an invalid or 'don't care' logical state.
Progress--which calls null "unknown" has four distinct unknown values for some reason (probably because it makes the engine coding easier), not that you can programmatically distinguish them, and none of which are equal to any of them, or, indeed, anything else. :)
I can see how those two things, it makes sense for them to be distinct.
-
-
Worst IDE ever.
Never used the old DOS edlin, eh?
Yes, I know it's--technically--not an I or maybe an E.
-
Haven't used Character Map as an IDE?