- 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
frist business comment of month
Admin
Is the next part of the series going to be
IntManager
? Because obviously, to get Maximum Performance out of integers you gotta cache the different value instances to prevent runtime allocations of already allocated integers. Every byte counts.Admin
Am I the only one to read _bldr and interpret it as "bleeder"? Because that's the effect it has on my eyes.
I am reminded of a programmer who was assigned a task which included "... and put today's date in here, ..." or whatever.
So he carefully programmed in something like:
this_string = "3rd September 1995";
or whatever day it was that day. And yep, you guessed, when the testers came back to him a week later and said, "The date's being output wrong, it should say the tenth," changed it to:
this_string = "10th September 1995";
recompiled it and re-released it to test.
Admin
The sad part is that some day, someone will be searching for date routines and find the whole source code for Initrode.Utilities and start using it in their app.
Admin
The spelling of "getLastDayofTheInputtedDatesYear" (correct: capital O and remove "ted". refactored: getLastDayOf(date.Year)) reminds me of a library I had to use that got the grade A in university. It contained over 20 methods with the word "piece" spelled as "peice". I had to use them so often that I started spelling it wrong, too, and got confused when i saw it spelled right later on in my life. But the best was the method "getPopAlter". No, it does not get an alternate pop-up. It also does not change the stack by removing an item. It gets the age of a population. Do you not know that "Alter" is the german word for age?
Admin
'the testers came back to him a week later and said, "The date's being output wrong, it should say the tenth,"'
Surely the testers said 'it should say today's date' and he changed it to 10th Sept?
Admin
This is one reason I don't think I could handle consulting or contractor-type work. I'm sure this type of thing is a minority of potential clients out there, but my OCD would compel me to refactor the entire class to be a wrapper around the built-in methods or replace all calls to the class to built-in methods (depending on how widely it's used), and stand my ground when confronted by the local expert beginner. I'm also sure in such a situation I wouldn't last long.
Admin
Will there also be a floatManager? I need one for my next project and this could save me lots of time.
Admin
Funny, I ran into a very similar problem just last month. I was dealing with some scheduler code that would periodically schedule a recurring task, but it would sometimes go crazy and spam the scheduler with tasks just before midnight. Turns out that they were using a homebrew Time class (not a DateTime, but just Time) and weren't accounting for the rollover when, say, 23 + 2 = 1.
Admin
Like I said for their StringManager ...
This looks like somebody's pet library from the days of TurboPascal, repeatedly ported (but never refactored) to the then-current API / language du jour.
Back then you DID have to roll your own. So as a whole it wasn't a WTF when new; it was DRY as DRY was practiced back when the "structured programming" paradigm was morphing into the early days of OO.
What's a durn shame is that somehow in the intervening 35 years nobody was able to break the cycle of port-and-re-use. Idjits.
Admin
If only the guys who rewrite "Date" would go on one instead of writing code.....
Admin
I tend to think of Entity Framework as the real WTF... (database knowledge, stored procs and some battle-tested mini ORM like Dapper is usually all you need)
Admin
"Alter" is also a colloquial term meaning "dude" (lit.: "old guy"), so I'd read the method name as "get me a pop, dude".
ObXKCD: https://xkcd.com/2108/
Admin
"... go on a date..." Insert standard /. reply about Mom's basement and #nevergonnahappen
Admin
currentDateIsFirstBusinessDateOfTheMonth is not good code, but (unlike most of the other functions here) does seem to have a purpose and is salvageable:
Make the date a parameter. Allows for real unit testing without the danger of leaving a hard-coded test case in the code. If you need to call it with the current date very often, write a trivial wrapper for that.
Speaking of which: Do some real testing. 2010-05-06 is not a particularly interesting test case. 2010-05-03 would be more interesting as it the first business day of the month, but not the first day of the month. But obviously, test on more than one case. :)
Factor out isBusinessDate. It's needed twice in this function already (and likely elsewhere, too), so it's definitely worthwhile.
Get rid of the middle check. This should work as a special case of the later check (of course, test that). If you're afraid of empty loops, get a therapy.
Sure, doing all that wouldn't leave much of the original code, counting by lines. But the basic approach is correct, and Remy's question "why does it need to cycle through other days" has an easy answer: Because it needs to know if any of those other days are business days.
Admin
That's what StackOverflow is for
Admin
I've had situations like that where the spec was ambiguous, and no matter how many times you ask for clarification you don't get a straight answer or worse you're told everything is in the documentation.
Sure, using "today's date" rarely makes sense, but depending on the circumstances valid dates would be when the software was installed, first run, last run, the PC was booted, the current work day, the current day, the next work date, and so on.
So you work with what you're given, and if the client is someone who doesn't know the difference between IE and EG they get what they say they wanted.
Admin
I would say they should write some unit tests, but knowing these guys, the tests would take a month to run so you they could cross a new month boundary.
Admin
"What's a durn shame is that somehow in the intervening 35 years nobody was able to break the cycle of port-and-re-use. Idjits."
I'd like to have a job where I could go through old code and rewrite it. Do these actually exist?
Admin
I get to do it in periods of downtime. I just keep a list, and if I finish something a couple days early I spend that time on cleaning up old code. It is quite satisfying to replace huge swathes of unreliable cruft and replace them with a call to a single built in c# method that actually works.
Admin
For the next episode in this epic (fail, obviously), I expect a peek at the unit tests that test these methods against the built-in routines. I already feel goosebumpily exhilirated...
What? What do you mean? Not there? Noooooooooooooooooo...
Admin
I could go for a nice dateTime Parm sandwich.
Admin
It took some time before I realized that the first-calendar-date-check would actually work, because "1 - _currentDate.Day" evaluates to "0" when _currentDate.Day is 1.
In other words, this code:
is equivalent to:
Admin
"reminds me of a library I had to use that got the grade A in university"
English, please.
Admin
Does anyone actually bother reading the longer snippets?
Huh? It's to protect my brain from corruption, of course!
Admin
If these are their managers, imagine what their subordinates (associates) are like.
Admin
Alter Popalter! Of course it is utterly important to also use a aCorRectWayOf.caMelCaseCaPiTaLiZaTion(eVeRyWhere) so it appeals to the reader's eye, because now it looks really professional.
Admin
I'm pretty sure that those people work for us...
This is my boss' idea of Clear and Robust code.
Admin
The liberal use of hashes in the code make me think there was liberal use of another type of hash during the writing of the code as well. And I am not talking about a fried potato preparation for breakfast.
Admin
I was at a tech conference recently where a well respected speaker made the comment “Of course, you should wrap all calls to third-party libraries”. This was stated as a matter-of-fact, everyone-knows-this kind of thing. It goes along with the principle of “don’t mock what you don’t own” (referring to the test-double kind of Mock, not the activity of us all here reading The Daily WTF).
Unfortunately, it seems that the definition of “third-party” is a bit vague. Perhaps no-one told this developer that he could ignore that rule for the system libraries?
Admin
This type of problem will still be ongoing in the 24th century as even the feeration of planets apear to have major inconsistencies with their starate system https://en.wikipedia.org/wiki/Stardate :-)
Admin
When you're doing cross platform development you should treat at least some system libraries as 3rd party libraries.
Admin
Oh yeah, been there. The article page is nothing. Read the Talk page for some real insight into the weirdness (though most of it is theories by fans refusing to accept that it was all made up on the spot without any real systematic behind it).
Admin
"If only the guys who rewrite "Date" would go on one instead of writing code." Oh no, then they might reproduce!
Admin
Perfect, I was looking for some date handling code to copy to my projects.
Admin
I'm the "Deon" that originally posted this. Sometimes when I'm having a bad day at work, I come back to these two articles to remind myself that it was once much worse.