|
I suppose that's kinda the point of the loop in the first place: To prevent the user from doing anything else in the meantime.
|
|
|
|
|
Yes but user should be still allowed to do stuffs such as clicking on menus or continue typing. Using async method gives user smooth experience. While using thread.sleep and window.doevents continuously wont be smooth, I believe.
|
|
|
|
|
For starters, I don't mean to defend the code. It's a clear code smell and should be restructured to be asynchronous proper.
That said, it can be smooth depending on the interaction rate. No process in computing ever is smooth in reality, it's just granular on a fine-enough scale to make us, slow-reacting meatbags, think, it's smooth. In gaming, 60 FPS are, as a rule of thumb, pretty enough to make things feel smooth so if the application processes messages 60 times per second, that would feel smooth despite doing busy-wait-nonsense.
|
|
|
|
|
That smtp call followed by the loop stinks of a VB6 port. I had to write garbage like this in VB6.
|
|
|
|
|
Quote: And I REALLY don't know what to make of this
Simple: it's a chunk of code which says "I have absolutely no idea what the I'm doing".
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Did somebody also comment out code, then leave it to be checked into the repository? That's a sure sign too.
yes, I deal with that on a daily basis.
Them: "What if we ever change the repository? Then we lose all that history!"
Me: "Who * cares? The application should support the business rules at this point in time. If those ever change, we need to understand how to make the application work differently, and write that code. Having this clutter around just makes the code less readable."
|
|
|
|
|
happy to hear it's not just me. I'm okay with commenting out code and forgetting about it - we all do it from time to time. HOWEVER, having multiple levels of commented out code so that you can see the history (yet we're using svn...), yeah, that's either stupid or a bad habit.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
Seems like it would be a very unresponsive message pump, given the half second interval between processing events.
Explorans limites defectum
|
|
|
|
|
|
At least emailing is something that the user expects to take a few moments...
|
|
|
|
|
"Application.DoEvents" ... i remember that one well; it was a mantra we used to sprinkle liberally on VB code (the dinosaur VB of the late neolithic, that is) when things got weird (and, they always got weird).
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
It could be worse in case of c++...
I faced the situation when inherited from a class which implement a method "Sleep".
For a lazy implementation while inheriting from that class I called Sleep in the assumption I'm calling the W32 Sleep. But instead of, it ended in something like this:
for (i = 0; i < 5; i++)
{
ProcessMessages();
::Sleep(0.2 * cnMilliseconds);
ProcessMessages();
}
I could kill that beast
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
I've come across C++ code where you would see several sleeps in a row just to "resolve" a timing issue.
sleep(0);
sleep(0);
sleep(0);
sleep(0);
sleep(0);
Of course after the code was properly debugged I was able to eliminate all of the sleep(0) lines.
Kelly Herald
Software Developer
|
|
|
|
|
Some smtp systems don't like receiving too many send requests too close together, so you got to spread them out if say sending bulk individualized email.
(if you're relying on your ISP's mail handlers to send they purposely force inter-message delays to avoid spammers - often they'll let 5-10 go but then force you to wait before the next one will be allowed.)
I dealt with such myself for a client, needed to send monthly billing invoices (tens to few hundreds each day). Luckily in my case this ran overnight [batch job] so while I did have to incorporate a single (not loop of) 1/2 second sleep between messages.
Actually I could reduce that down to 1/10th second, but being overnight why ride the edge? I didn't want to push it and get bitten by say network spikes etc - at 1/2 sec worst possible case would be couple of hours.
As to doing it in a loop (not defending it, just saying) - amateurish way to enable easier tuning i.e. "perhaps 9 loops of 450 will still be OK" ... big-wheel-small-wheel tuning. Something like the [old non digital] radios that have 2 tuning knobs: "tuning" & "fine tuning."
Message Signature
(Click to edit ->)
|
|
|
|
|
However, notice that the SMTP call is NOT in the loop
It's just a single email, unless it's called from within a loop (which happens at least once, but at least three times it's just a single email).
So... I guess it may be what you're saying, but handled very poorly?
|
|
|
|
|
or this is a method called from within another loop [that is preparing the messages]?
|
|
|
|
|
I prefer the projects that have been going for a few years, and which has had multiple developers. You learn more from a brownfield than from a greenfield. Some applications contain more man-hours in knowledge than I can afford to spend.
So, you might not enjoy that particular work, but that's not a good generic reason for everyone to decline such an inheritance (which is what the title seemed to suggest to me).
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
"brownfield"?! 
|
|
|
|
|
Manning | Brownfield Application Development in .NET[^]
Sidenote; I reviewed the book before it got published.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Looks like a very practical book!
|
|
|
|
|
|
It's named after the color of a steaming pile of...
(Probably not, but I like to think so and it's often true)
|
|
|
|
|
Any farmer will call that a fertile field
Our carrots were fertilized with cow-dung. We ate them without washing them.
George Carlin - Germs, Immune System - YouTube[^]
"You gonna get sick, you gonna die, and you gonna deserve it, because you fakking weak and you got a fakking weak immune-system".
"The polio never had a prayer; we were tempered in raw sh*t"
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Not this project.
Unless you want to learn how NOT to do things...
Such inheritance is often a bad deal since you'll be spending two to three times as much time as the old party to fix bugs while the chances of introducing new bugs increases.
Meanwhile, you're working half price since you can't invoice all the hours you're making.
And if you introduce enough bugs you may end up with an unhappy client.
"But the former programmer made a mess out of things!" is not a valid excuse.
Like today I had to "just fix a form, everything worked except a value was not saved to the database."
Opening the form revealed it had all kinds of buttons that did nothing (or worse, did something) and shouldn't be there.
There was binding in place, but everything was inserted directly into the controls.
So I added something to the binding, then the application crashed because you can't do both, then I removed the binding and the designer thought it necessary to reflect that...
Long story short, after trying to make it work for about an hour I started over, finding not even the database schema was correct.
It took me about four hours in total (which should've been a "quick fix"), which is more than the customer is going to pay me for this one
If that was all, I could've gotten away with it, but this is one of many such changes.
Eddy Vluggen wrote: that's not a good generic reason for everyone to decline such an inheritance Of course.
I inherited is as well, after all.
You just need a damn good reason (and I know a lot of companies that simply don't, ever)
|
|
|
|
|
Sander Rossel wrote: Unless you want to learn how NOT to do things... Learning is learning. Imagine a project, over 10 devs, over 10 yrs old. In VB6. Don't complain about some idiot storing bools as a list of strings in a database ("0010101010101000010101"), because the idiot might be your boss.
Sander Rossel wrote: Meanwhile, you're working half price since you can't invoice all the hours you're making. Your own choice. I get paid for the actual hours I work.
Sander Rossel wrote: And if you introduce enough bugs you may end up with an unhappy client. Who'd expect that?
Sander Rossel wrote: Like today I had to "just fix a form, everything worked except a value was not saved to the database."
Opening the form revealed it had all kinds of buttons that did nothing (or worse, did something) and shouldn't be there. Sometimes a fix is more expensive than expected. Just add it to the bill, it's what any car-mechanic would do. Why don't you?
Sander Rossel wrote: Long story short, after trying to make it work for about an hour I started over, finding not even the database schema was correct.
It took me about four hours in total (which should've been a "quick fix"), which is more than the customer is going to pay me for this one If you want to be an entrepeneur, you take risc. I'm just a simple slave, so I don't know about riscs.
Sander Rossel wrote: You just need a damn good reason (and I know a lot of companies that simply don't, ever) I don't need a reason, I do what I am paid for. I can point you to companies that don't exist anymore because they believed a rewrite was needed
You good at greenfields, me good at brownfields; a good team has balance
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|