• Brian Boorman (google)

    if (fristComment && !fristComment()) // just stop commenting

  • The Dave G (unregistered)

    When you look at bad code, there's a part of your body that reacts to it. Your head explodes.


  • WTFGuy (unregistered)

    @Remy ref:

    Spleen-oriented Programming is where you make sure none of the code you have to touch makes your spleen hurt.

    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.

  • ray10k (unregistered)

    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.

  • (author) in reply to ray10k

    That's another hint that SaveChanges() goes to the database, but yeah, that should probably be awaited.

  • John (unregistered)

    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.

  • Sole Purpose Of Visit (unregistered) in reply to ray10k

    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.

  • 516052 (unregistered) in reply to Sole Purpose Of Visit

    In times like that I like to reply with: "And than you ask me why I drink."

  • Brian (unregistered) in reply to Sole Purpose Of Visit

    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.

  • Sole Purpose Of Visit (unregistered) in reply to 516052

    It's funny you should say that ...

  • Appalled (unregistered)

    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"

  • Sole Purpose Of Visit (unregistered) in reply to Appalled

    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."


  • (nodebb)

    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?

  • Sole Purpose Of Visit (unregistered) in reply to Remy Porter

    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.

  • Loren Pechtel (unregistered)

    Case sensitivity--not even once!

  • (nodebb)

    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.

  • Some Ed (unregistered) in reply to The Dave G

    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.

  • jochem (unregistered) in reply to Sole Purpose Of Visit

    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.

  • (nodebb) in reply to Mr. TA

    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 return Task or Task<T>, but that doesn't enforce the use of async. 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.

Leave a comment on “Saved Changes”

Log In or post as a guest

Replying to comment #:

« Return to Article