| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
YES! I did it only took me 27 days
|
|
Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........
|
|
Obviously done for extensibility. If you tie this kind of thing to tenuous structures like DateTime data types or Calendar functions, you'll be sorry when the calendar changes. Just think about all those programmers working when the Gregorian calendar came online. They were spending weeks recoding. Our friend here can just set a few bits and he's all set. You youngsterd think y2k was bad, you just don't remember y1582. Ugly, man. Ugly. Better to roll your own calendar functions than go through THAT again.
|
|
This still doesn't match the amazing power that Microsoft has to reschedule Thanksgiving to fall on a Wednesday:
http://72.14.203.104/search?q=cache:RzFeU2G46_8J:blogs.msdn.com/jensenh/archive/2005/11/23/496246.aspx+microsoft+bug+thanksgiving+tuesday&hl=en&gl=us&ct=clnk&cd=2 |
|
blnaryHoliday?
booleanary? |
I also like that in a table tblHoliday, and a field named blnaryHoliday, that the days marked with a "Y" are NOT holidays. Just another little bundle of joy. |
|
This conversation probably happened a couple of years later, after the original developer moved to a new company:
Original Developer: "Yeah, so I didn't want to have to go through each calendar year and figure out weekends, weekdays, and holidays manually. So I populated this table auto-magically by writing a script to iterate over years from 1975, and figure for each day whether it was a weekend or holiday. Saved me loads of time." Rookie: "Why didn't you just... you know... like, adapt the code from that script, instead of... well, instead of storing it in the database like that?" Original Developer: "Ah! You are obviously new to enterprise development!" |
|
Man, I want to work for that company. You only have to work for 2 days and then you get 5 holidays!!
|
|
Because if you used logic instead of Ys and Ns you'd drastically increase the size of your database:
TRUETRUEFALSEFALSEFALSEFALSEFALSEFALSETRUETRUEFALSE FALSEFALSEFALSEFALSETRUETRUE ... |
I don't think "logic" is the way to go (not sure how you'd logically work out what the holidays would be, anyway -- plus, what happens when that "logic" changes?). However, you could just put the dates in the table as dates, maybe with a nice little description for the holiday in a separate column. Plus other column flags like which country it's a holiday for, or whether it's a trading or settlement holiday for finance, or whatever. Of course, logic works for weekends. Is it just me who only sees weekends defined on this chart? |
|
That threw me off, why are the non-holidays marked "Y"?!
|
|
365 bytes, what a waste! Packing it to one bit per day would reduce it to 46 bytes!
And you still have 1 bit available to store other stuff, and 2 bits in non-leap years! |
|
Should probably be bInaryWORKDAY (Y/N)
Can't believe I am suggesting naming improvements for this nightmare. I guess I need something to do.... |
|
The really funny thing is that it should be called "tblWeekends".
|
|
And it works great overseas. All you have to do is create a new table and determine other countries holidays.
|
You see, when you get to work with code like that....each work day is just like a holiday. I'm so super jealous. |
|
laughable... this fellow clearly has no idea about enterprise systems.
he should have had another table called "days", where each row contains the current date. a daily cron script can then kick off each day to add a row to the days table, which of course has a trigger that calls a stored procedure which automatically appends a "Y" or "N" to the proper row in blnaryHoliday. |
|
A more "enterprise" way to do this would be with two tables:
one to enumerate holidays... and one to enumerate non-holidays! |
|
I agree -- there are NO holidays listed in that table, only the weekdays are marked Y. Apparently there are no holidays, or else every weekday is a holiday.
|
Ah yes, then you have truly mastered Zen Programming. |
The ENTERPRISE way to approach this problem is to use a simple CRON routine that;
if it matches this must be a weekend or holiday!
VOILA!
|
|
Surely, this should have been ... <1975>
or even \1975
(... hoping the forum does not screw the layout ...) |
rofl that is fuckin funny shit. |
|
This is actually a GOOD approach... caching calculations.
It should have been coupled with some kind of mechanism for generating rows for future years, though. |
|
Caching calculations MIGHT be a good approach IF it turns out the calcuation is a bottleneck. You can't figgure that out without profiling it. Even then we're assuming that it takes less time to go out to the database and parse that mess instead of doing the calculation in the first place.
Either way, you can't know without profiling, and if it turns out that hitting the database is more efficient, well there's surely a better way of doing it than this bit of WTFery. |
You're close, but not quite there. It SHOULD be called "tblWeekdays" |
|
Ok, I see "T" and "F", but what about "File not found?"
In all seriousness, I would love to see the rest of this "database." or maybe not. Great post Alex. WTF ++ ! |
Holidays are *data* and should be stored in tables. However, as mentioned, it appears that he is simply declaring every weekend a "Holiday" so in that case logic would work, I suppose. The guy who wrote this must be a fun guy to hang out with ... except for Monday-Friday or on any actual holiday that falls on a weekday, that is. |
|
If you want a real solution you should use the following table instead:
CREATE TABLE tblHoliday ( intYear INT, bln0101 BIT, bln0102 BIT, bln0103 BIT, ... bln1231 BIT ) |
|
[:S] Okay--just so I don't end up the guy who has to make sense out of the WTFs for holidays-- The right way to track holidays is to manually enter them into a table. Most holidays can be mathematically calculated (3rd Monday of January, for example, for Martin Luther King's birthday), but some are rather complex in their formulas (every try to calculate Easter?) Some years a business will observe one holiday, while on others it will observe a different holiday. Safest to always just put the list of observed holidays in a database. And, for goodness sakes, just have a table with nothing but the actual date of the holiday:
Holiday Table (or whatever you want to call it) Date (a "Date" datatype, please) | Description (optional column) 12/25/2006 | Christmas
|
Because that will be your response. "YYYYYYYYYYYYes! I get to go to work!" That's how awesome working for this company is. |
1. For blind people being driven to the ATM. 2. Notice there is Braille on all ATMs, including those walk-up ones in the mall and at banks. Does it make sense to manufacture some ATMs with Braille and some without? No, of course not - make one mold, keep filling it. 3. Americans with Disabilities act is probably another reason. There, three reasons for you. Change your signature. sincerely, Richard Nixon |
|
Man, I bet the leap year code for this mess is hell awesome.
|
|
When did Christmas stop being a holiday?
|
Obvious! This company only gives you a holiday off if that Holiday falls on a weekend |
boolean array maybe |
|
In the financial programming world, we all have 'holiday' tables. That part makes sense. Using a logic based solution would not be practical. Remember when Ronald Reagan died, the markets had a holiday added. Inserting one row into a 'holiday' table was easy, maintaining and releasing code is unfeasable.
Not using a datetime field for the holiday dates is what makes no sense.Using a database in such a way, that you can't possibly 'JOIN' to the required data is the WTF. |
You mean that not everyone celebrates the 4th of July? Weird. [:D] |
During the War On Christmas, obviously. I guess Christmas lost. |
When the Christmas-hating liberal media got hold of the calendar industry. |
|
scrooge@gold> mysql -uscrooge -pm0n3y
mysql> USE dbHoliday; mysql> UPDATE tblHoliday SET binaryHoliday = INSERT(binaryHoliday, LENGTH(binaryHoliday)-6, 1, 'Y'); |
What do you mean you can't use logic to calculate the holidays? There are rules for figuring out holidays and when they fall each year, they don't generally change. And yes I think you're right, I also do not see any holidays defined in this, only weekends. |
In the end, it was decided that 'F' would signify both False and Filenotfound, in the interest of saving precious bytes of memory. A random number would be generated, and then the mod(2) taken, to determine which value the current instance of 'F' implied. |
Sorry every holiday has an exact calculation ... in Excel for instance they can represented like: Memorial Day - Last Monday in May =DATEVALUE("5/" & IF(WEEKDAY(DATEVALUE("5/31/" & intYear))>3, 35 -WEEKDAY(DATEVALUE("5/31/" & intYear)),28-WEEKDAY(DATEVALUE("5/1/" & intYear))) & "/" & intYear) How you want to cache the results depends on your needs.
I sure wouldn't want to work for that company. No holidays!
|
I should mention that the technical term for this logic is "WTF Overloading". |
|
This is actually GREAT! Finally a date system that can take leap-seconds into account on the scale of years :D
|
easy: yes == yes, it is not a holiday no == no, it is not not a holiday |
Cool! Can you show me the formula for Easter next? |
|
The real WTF here is that the original programmer didn't have the foresight to insert the days as XML entries into the database.
|
| « Prev | Page 1 | Page 2 | Page 3 | Next » |