- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
if (fristComment && !fristComment()) // just stop commenting
Admin
When you look at bad code, there's a part of your body that reacts to it. Your head explodes.
FTFY
Admin
@Remy ref:
Well said.
The only problem is that if most of us implemented that rule we'd quit tomorrow and be unwilling to take most IT jobs. Then civilization would quickly grind to a pre-computerized halt.
We're like that proverbial "thin blue line" that (supposedly) sacrifices their spleens, livers, and mental health to support civilization's uncaring head just above the sewage-infested waterline of chaotic villainy / WTFery.
Admin
Also got to love the Async in the function signature. What does this function do that could take long enough that you'd want to run it asynchronously? And while it's been years since I last worked with C#, I recall that having an async function that doesn't use await anywhere is, at least, a warning.
Admin
That's another hint that
SaveChanges()
goes to the database, but yeah, that should probably be awaited.Admin
I'm guessing that dataGrid.ItemSource was really dataGrid.ItemsSource, in which case I'm also guessing this is WPF. I'd say a bigger issue is they appear to be setting this stuff in the view's code behind instead of using MVVM and binding.
Admin
Not necessarily: if all async methods are side-effect free, you don't really care. It's not my idea of proper parallel programming, but there you go. It's also possible (but unlikely, given the WTFs) that the calling site can order the processing to separate out little side-effect free contexts.
We at my place of work have two separate massive dlls that communicate exclusively via a stream of async calls with no awaits. I've tried explaining how this doesn't make sense. I've tried enquiring that, if we order our calls as a, b and c, we will need responses in the order a, b and c. Their answer is that they execute the calls as a, b, c, which of course doesn't help on my side because there's no guarantee that the responses are sequenced.
Every time I point out what a cluster-wtfery this is, they all go off in an all day meeting and at the end of it tell me they're going to stick with this "optimisation" and that I don't know what I'm talking about.
My spleen is numb.
Admin
In times like that I like to reply with: "And than you ask me why I drink."
Admin
For me, it's not so much my spleen as this little spot just behind my eyes that gets a numb feeling and starts whispering "maybe it's time to check the job boards again..." Then the more rational side takes over and reminds me that a new job is unlikely to be that much different from my current one.
Admin
It's funny you should say that ...
Admin
Perhaps that's why I survived 34 years in the business. My spleen was removed when I was 17 after a football injury in high school. Never had any spleen feelings, just "Look at this shit, time to fix/rename/refactor/rewrite whatever. As long as I never have to look at it again, all is well"
Admin
This is probably why bosses never understand when you describe the WTF in excruciating detail and how it will destroy the product and what to do about it.
Obviously, from their point of view, you are "man-spleening."
(Sorry.)
Admin
If this causes your spleen to hurt, then our code base has killed mine.
WriteResults() sounds harmless enough to reuse, but would you expect it to contain spaghetti code for decodong whether to actually DO the write? And the spaghetti code explicitly takes i to account each call site of the function! For lack of automated tests I didn't have a choice but to add yet another elif...
Similar issues all around. A method may say "CalculateStuff" but also write out results to an output file. When invariably the requirements change based on user feedback, such code is a nightmare to refactor for the new behavior. Did I mention that there are no automated tests to at least make that change safe?
Admin
I presume that "SaveChanges()" results in a db transaction. Obviously, in any case, it is rich in side effects. But assuming the best (ie transactional semantics) there's no particular reason to insist that the developer sticks an await in there.
It's a general principle with parallel programming that somebody has to take responsibility for marshalling the map-reduce operation. However, that somebody could be just about any part of the stack.
Given a proper design, sensible semantics, and decent programming, of course. The kindest thing I can say about today's WTF is that it doesn't actively prove that the design is borked, the semantics are swivel-eyed, and/or the programmer is metaphorically standing naked in a snowstorm on Titan.
Although I imagine all three propositions are true.
Admin
Case sensitivity--not even once!
Admin
Async and no await is useless. And it is a warning. However sometimes it's needed. Imagine a virtual method or an interface implementing method which can be async in some cases. Then you suppress the warning. But really they should exclude those by default.
Admin
Different people are different. I first saw phenomenon being talked about reported on http://wiki.c2.com/?CodeSmell. This is one of those cases where the generalized you really means 'me', because Remy feels it in the spleen, The David G feels like an imminent head explosion, and I feel it as if I'm touching a really bad texture with the back of my hands. Massimo Arnoldi feels it as a bad smell, which is where the term 'code smell' came from.
While I agree that this is a clear indication of problematic code, I don't feel like it's a guarantee that the SaveChanges routine is necessarily spaghetti code. It is, however, a virtual guarantee that whomever wrote SaveChanges() wasn't comfortable with exceptions at the time they wrote it.
It also doesn't necessarily mean that the routine catches exceptions when it shouldn't. It could instead be doing some premature detection to avoid exceptions, or it could let the exceptions happen, but do a check to make sure the changes it would be saving are actually in a saveable state. Those checks could be performed in another routine that SaveChanges merely invokes, and since it probably would've been written around the same time or earlier, and likely by the same programmer, it's also not comfortable with exceptions, so it returns a boolean, and if SaveChanges sees the wrong return, it simply returns immediately.
Admin
Well, at least you can use async. In our asp.net monolith we're not allowed to use async as the lead architect doesn't "believe" in them. "They add state machine overhead", etc. He doesn't want the computer to do "other stuff", it should just do what he wants it to do faster instead. Tried to reason with him, but gave up.
Admin
async
is not actually part of the method signature, but an implementation detail. If you want the work's asynchrony to be part of the signature, the method needs to returnTask
orTask<T>
, but that doesn't enforce the use ofasync
. Instead the method could manually construct a task and directly return that.All
async
does is instruct the compiler to transform the body of the function into an async state machine so you can write your asynchronous code as though it were synchronous.