Comment On Automatic Updates

Deaper visits a software vendor's website every once in a while to check if they've announced any new products, services, rates, or the like. One thing he noticed was bit silly about their site is that, although content is updated every few weeks, they had a big block of text stating that the last update just happened to be done on the same day you were visiting the site. [expand full text]
« PrevPage 1 | Page 2Next »

Re: Automatic Updates

2005-10-13 13:53 • by CAPTCHA Man!
I'm willing to bet there use to be stuff in there and something broke
one day and an intern was told to "just make it work again".

Re: Automatic Updates

2005-10-13 13:59 • by Brillant Bob
46787 in reply to 46786
Anonymous:
I'm willing to bet there use to be stuff in there and something broke
one day and an intern was told to "just make it work again".




It is a bit scary to think that the previous code was likely worse than this.

Re: Automatic Updates

2005-10-13 13:59 • by Dominic Adelaar
I'm not sure what the hell was happening in the first snippet, but I'm
thinking in the second the author probably didn't know about
Date.getFullYear (?) perhaps, and since he needed a full 4 digit date
which Date.getYear doesn't provide, just wrote it in. Although in that
case why he didn't write '20' + Date.getYear, I have no idea.



That's the only reason I can come up with.

Re: Automatic Updates

2005-10-13 13:59 • by Chuck
Ha!
So we always want to say Last Update, but we may change it in the future...maybe
Last Update was this morning on
Last Update was the afternoon on
Last Update was this evening on

Then we need to add one to our times because heaven forbid that we compare against zero.

And wouldn't it have been easier to just put the days of week/months in arrays like

var now = new Date();
var days = new Array("Sun.", "Mon.","Tues.","Wed.","Thurs.","Fri.","Sat.");
var mths = new Array("Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sept.","Oct.","Nov.","Dec.");
document.open();
document.write(mths[now.getMonth()] + " " + days[now.getDay())] + " " + now.getFullYear());

And they introduced the entire Y2K4 bug into the script...

Re: Automatic Updates

2005-10-13 14:17 • by Hrolf


I see, the WTF is the magic numbers in the front section. It should be:



var lunchtime = 12;

var millertime = 17;



That would be much clearer.

Re: Automatic Updates

2005-10-13 14:25 • by kipthegreat
This one's stupid weak.  So many problems with it, but so
obviously an unimportant task appropriately handed off to someone
inexperienced, who used the "tweak it until it works" scripting
technique.  Certainly not code that is critical or frequently
maintained.  My guess is that it was written in about thirty
minutes and never looked at again.

Re: Automatic Updates

2005-10-13 14:39 • by hank miller
Hey, at least it will continue to function the same when you change web
browsers, or server scripting langauges or platforms.   You
can even mix and match to your hearts desire.   Trying to
deicde between ASP, ASP.net, PSP, ruby on rails, uncommon web, JSP, or
any have several hundred other scirpting languages on the
server?   Maybe you have some Solaris servers, a Mainframe,
and Windows, and are not sure which is best for running your web server
on?   No problem, just write your code once on the client
side (where you only have one choice), and drop it in anywhere, fully
confident it will work the same no matter what you choose for your
backroom.



Brillant!

Re: Automatic Updates

2005-10-13 14:51 • by RiX0R
I like the first part. Especially the indentation.

Re: Automatic Updates

2005-10-13 14:57 • by Odoyle rules!
46798 in reply to 46794

Forgive me for my simplistic view but isn't the biggest WTF that fact that the last update doesn't reflect anything other than the user's clock?

Re: Automatic Updates

2005-10-13 15:00 • by A Wizard A True Star

So, wait, "monthName" contains the month number? And then "Month" (never declared) contains the month name?


And not only does "dayName" get a number, and the undeclared "Day" get the name, but neither variable is ever used for anything.


What crap.


 

Re: Automatic Updates

2005-10-13 15:01 • by Richard Nixon
46800 in reply to 46798
Anonymous:

Forgive me for my simplistic view but isn't
the biggest WTF that fact that the last update doesn't reflect anything
other than the user's clock?





Nope - that's a reflection of the corporation's overall relationship
with the customer. The company last updated whenever the customer says
they did.

Re: Automatic Updates

2005-10-13 15:08 • by Gene Wirchenko
46802 in reply to 46798
Anonymous:
Forgive me for my simplistic view but isn't the
biggest WTF that fact that the last update doesn't reflect anything
other than the user's clock?




Well...



Since the page is generated dynamically, at least for the last update<EG>, that is accurate in a way, in a WTF way.



Sincerely,



Gene Wirchenko



Re: Automatic Updates

2005-10-13 15:09 • by OMG

Aw, come on, it was right for a whole year, that's not too bad. Even a Mercedes needs to go back for maintenance that often.......


 


Man, this one made me laugh out loud - Best punchline code I've seen in ages!

Re: Automatic Updates

2005-10-13 15:20 • by Manni

I don't know if I should be impressed or nauseated that someone went through all this trouble to learn how to print a date, and then assumed this would only be used until December 31, 2004. Get the day, get the month... why not just get the year too!?


Maybe there's an action item on someone's list that states every January 1st someone needs to edit this document to update the year. Or better yet, someone calls this "developer" every year to say "Oh no! The website is showing LAST YEAR'S DATE!!! Can you help us!?"  "Yep, I sure can. It will cost $2,000 to fix this bug. See you next year."

Re: Automatic Updates

2005-10-13 15:25 • by Richard Nixon
46805 in reply to 46802
Gene Wirchenko:
Anonymous:
Forgive me for my simplistic view but isn't the
biggest WTF that fact that the last update doesn't reflect anything
other than the user's clock?




Well...



Since the page is generated dynamically, at least for the last update, that is accurate in a way, in a WTF way.



Sincerely,



Gene Wirchenko






I respectfully disagree with that summation.



Sincerely,



Richard Nixon

Re: Automatic Updates

2005-10-13 15:28 • by noturavgdba
46806 in reply to 46804

Re: Automatic Updates

2005-10-13 15:31 • by noturavgdba
46807 in reply to 46804
Manni:

I don't know if I should be impressed or nauseated that someone went through all this trouble to learn how to print a date, and then assumed this would only be used until December 31, 2004. Get the day, get the month... why not just get the year too!?


Maybe there's an action item on someone's list that states every January 1st someone needs to edit this document to update the year. Or better yet, someone calls this "developer" every year to say "Oh no! The website is showing LAST YEAR'S DATE!!! Can you help us!?"  "Yep, I sure can. It will cost $2,000 to fix this bug. See you next year."



sorry, replied instead of quoted - http://despair.com/consulting.html

Re: Automatic Updates

2005-10-13 15:40 • by Rainman
46808 in reply to 46798
Well, technically, it was the user's clock in 2004.

Re: Automatic Updates

2005-10-13 15:50 • by Rank Amateur
46809 in reply to 46788

Dominic Adelaar:
I'm not sure what the hell was happening in the first snippet, but I'm thinking in the second the author probably didn't know about Date.getFullYear (?) perhaps, and since he needed a full 4 digit date which Date.getYear doesn't provide, just wrote it in. Although in that case why he didn't write '20' + Date.getYear, I have no idea.


More likely, he started writing:


var yearNumber = now.getYear();
if(yearNumber==0) Year= "2000";
if(yearNumber==1) Year= "2001";
if(yearNumber==2) Year= "2002";


And then he thought, "God, I don't want to do this 100 times. I'll just put in 2004. I'll be working somewhere else a year from now."


Of course if he had known about getFullYear, he would've started with:


var yearNumber = now.getFullYear();
if(yearNumber==0) Year= "0";
if(yearNumber==1) Year= "1";
...


--RA


 

Re: Automatic Updates

2005-10-13 15:57 • by RyGuy
46810 in reply to 46809

Forgive me for my simplistic view but isn't the biggest WTF that fact that the last update doesn't reflect anything other than the user's clock?


++

Re: Automatic Updates

2005-10-13 15:58 • by JohnO
Well, at least the algorithm is O(1).

Re: Automatic Updates

2005-10-13 16:16 • by A!
46812 in reply to 46804
Manni:

I don't know if I should be impressed or nauseated that someone went through all this trouble to learn how to print a date, and then assumed this would only be used until December 31, 2004. Get the day, get the month... why not just get the year too!?



Maybe they didn't anticipate to stay in business that long.

Re: Automatic Updates

2005-10-13 16:28 • by Jeff S
46813 in reply to 46809
Rank Amateur:

Dominic Adelaar:
I'm not sure what the hell was happening in the first snippet, but I'm thinking in the second the author probably didn't know about Date.getFullYear (?) perhaps, and since he needed a full 4 digit date which Date.getYear doesn't provide, just wrote it in. Although in that case why he didn't write '20' + Date.getYear, I have no idea.


More likely, he started writing:


var yearNumber = now.getYear();
if(yearNumber==0) Year= "2000";
if(yearNumber==1) Year= "2001";
if(yearNumber==2) Year= "2002";


And then he thought, "God, I don't want to do this 100 times. I'll just put in 2004. I'll be working somewhere else a year from now."


Of course if he had known about getFullYear, he would've started with:


var yearNumber = now.getFullYear();
if(yearNumber==0) Year= "0";
if(yearNumber==1) Year= "1";
...


--RA


 



he he! Exactly !


And i do feel that the WTF is a combination of bad code and the complete misrepresentation of how often the site's content is updated.


 

Re: Automatic Updates

2005-10-13 16:32 • by anon
46815 in reply to 46811
JohnO:
Well, at least the algorithm is O(1).




Only because it employs "caching".

Re: Automatic Updates

2005-10-13 16:38 • by A!
As far hardcoding year.... maybe it is an optimiztion technique [:P]

Re: Automatic Updates

2005-10-13 16:44 • by meh
46819 in reply to 46788
'20' + Date.getYear will either display '2004' or '20104' depending on the browser.

Re: Automatic Updates

2005-10-13 16:46 • by meh
46821 in reply to 46819
Erm, I was in replying to Dominic Adelaar's post.

Re: Automatic Updates

2005-10-13 17:20 • by CornedBee
46823 in reply to 46794
hank miller:
Hey, at least it will continue to function the same when you change web
browsers, or server scripting langauges or platforms.   You
can even mix and match to your hearts desire.   Trying to
deicde between ASP, ASP.net, PSP, ruby on rails, uncommon web, JSP, or
any have several hundred other scirpting languages on the
server?   Maybe you have some Solaris servers, a Mainframe,
and Windows, and are not sure which is best for running your web server
on?   No problem, just write your code once on the client
side (where you only have one choice), and drop it in anywhere, fully
confident it will work the same no matter what you choose for your
backroom.



Brillant!




How about using XHTML?

Re: Automatic Updates

2005-10-13 17:53 • by richleick

Are we sure this isn't on a page that hasn't changed since 2004 ?


Whoever coded this obviously knew there would be no more updates after 2004, so I think we should give them credit for not trying to fool us into thinking that they have been updating this page.


[<:o)]


 

Re: Automatic Updates

2005-10-13 18:01 • by Brian
Makes me wonder if this is the same quality code used in this "Software Vendor's" software!

Re: Automatic Updates

2005-10-13 18:56 • by Jim Hauser

One of my students refered me to this site.[*]  It reminds me of a 1983 saying: Opus says "Don't look for logic." After 20 yrs in industry as a SE I thought I had seen it all...Hauser, PhD.  see www.nku.edu/~hauserj for a good review.  By the way .... building stuff is more fun; less rewarding.


 

Re: Automatic Updates

2005-10-13 19:14 • by Tony Morris
46833 in reply to 46791
kipthegreat:
This one's stupid weak.  So many problems with it, but so
obviously an unimportant task appropriately handed off to someone
inexperienced, who used the "tweak it until it works" scripting
technique.  Certainly not code that is critical or frequently
maintained.  My guess is that it was written in about thirty
minutes and never looked at again.




You seem to imply that rotten code is not critical or frequently
"maintained" (loosely speaking). Or that the worst code is written by
(claimed) "inexperienced" people. I sometimes wonder if there really is
an ideal world out there, but in my world, none of this holds true.

Re: Automatic Updates

2005-10-13 20:03 • by Jboy
Looks like they fixed it..



http://www.netcoast.nl/



 <script
language
="JavaScript">

var now = new Date();

var dayName = now.getDay() +1;
var dayNumber = now.getDate();
var monthName = now.getMonth() + 1;



if(dayName==1) Day = "Sunday";
if(dayName==2) Day = "Monday";
if(dayName==3) Day = "Tuesday";
if(dayName==4) Day = "Wednesday";
if(dayName==5) Day = "Thursday";
if(dayName==6) Day = "Friday";
if(dayName==7) Day = "Saturday";

if(monthName==1) Month="Jan.";
if(monthName==2) Month="Feb.";
if(monthName==3) Month="Mar.";
if(monthName==4) Month="Apr.";
if(monthName==5) Month="May";
if(monthName==6) Month="Jun.";
if(monthName==7) Month="Jul.";
if(monthName==8) Month="Aug.";
if(monthName==9) Month="Sept.";
if(monthName==10) Month="Oct.";
if(monthName==11) Month="Nov.";
if(monthName==12) Month="Dec.";

document.open();
document.write( Day + ", " + dayNumber + " " + Month);
</script>
2005</font>





Re: Automatic Updates

2005-10-13 20:10 • by Maurits
46839 in reply to 46838
LOL...

Yes, now when 2006 comes along even those with Javascript disabled will be able to see the incorrect year.

Re: Automatic Updates

2005-10-13 20:15 • by Cyresse
46842 in reply to 46788

Anonymous:
I'm not sure what the hell was happening in the first snippet, but I'm thinking in the second the author probably didn't know about Date.getFullYear (?) perhaps, and since he needed a full 4 digit date which Date.getYear doesn't provide, just wrote it in. Although in that case why he didn't write '20' + Date.getYear, I have no idea.

That's the only reason I can come up with.


He's writing "Last updated:" As long as the time returned is between 00 and 23 hours...

Re: Automatic Updates

2005-10-13 20:58 • by emurphy
46847 in reply to 46838
Anonymous:
Looks like they fixed it..



http://www.netcoast.nl/



 <script
language
="JavaScript">

var now = new Date();

var dayName = now.getDay() +1;
var dayNumber = now.getDate();
var monthName = now.getMonth() + 1;



if(dayName==1) Day = "Sunday";
if(dayName==2) Day = "Monday";
if(dayName==3) Day = "Tuesday";
if(dayName==4) Day = "Wednesday";
if(dayName==5) Day = "Thursday";
if(dayName==6) Day = "Friday";
if(dayName==7) Day = "Saturday";

if(monthName==1) Month="Jan.";
if(monthName==2) Month="Feb.";
if(monthName==3) Month="Mar.";
if(monthName==4) Month="Apr.";
if(monthName==5) Month="May";
if(monthName==6) Month="Jun.";
if(monthName==7) Month="Jul.";
if(monthName==8) Month="Aug.";
if(monthName==9) Month="Sept.";
if(monthName==10) Month="Oct.";
if(monthName==11) Month="Nov.";
if(monthName==12) Month="Dec.";

document.open();
document.write( Day + ", " + dayNumber + " " + Month);
script>
2005font>








OMFG it's real.



Re: Automatic Updates

2005-10-13 23:19 • by Paul O
46851 in reply to 46847
Shouldn't someone have commented by now that this looks like a great opportunity to use regex? :)

Re: Automatic Updates

2005-10-14 01:04 • by DeusEx
This kind of crap really bugs me:



Englishly Challenged:
if(dayName==4) Day = "Wed.";

if(dayName==5) Day = "Thur.";

if(dayName==6) Day = "Fri.";



if(monthName==6) Month="June";

if(monthName==7) Month="July";

if(monthName==8) Month="Aug.";

if(monthName==9) Month="Sept.";




Either abbreviate consistently or don't abbreviate at all. 3 letters
and a period is all you need. Did anyone ever think "Thu." was any
other day but Thursday? Or that "Sep." was a month besides September?



And yes, you should abbreviate "June" and "July" too.

Re: Automatic Updates

2005-10-14 01:16 • by Brandon Driesen
46856 in reply to 46802
When a page is declared to be updated, it means content being updated.
The javascript on the other hand, does nothing but just provide the
current date (with the exception of the year) and therefore is
DISINGENIOUS and DECEPTIVE.



Page being dynamically generated is irrelevant. If the content is the
same, the date cannot be today. The WTF here is clearly that the date
is not determined server-side whereby the actual date of the last
update could be retrieved from a data source, or hard-coded
client-side. Either solution is more honest and true than dynamic
client-side scripts that give the end-user the impression that the page
has just been updated.



More importantly, it would be obvious to that end-user were his computer time in the future.





Re: Automatic Updates

2005-10-14 01:27 • by jawohl
46857 in reply to 46819
Anonymous:
'20' + Date.getYear will either display '2004' or '20104' depending on the browser.
And thats why there's Date.getFullYear() which returns 2004.

Re: Automatic Updates

2005-10-14 01:31 • by badong
46858 in reply to 46856
They seem to have removed the "Last Updated" part. It's now only
stating the date, which imho is an important piece of information that
can come in quite handy.

Re: Automatic Updates

2005-10-14 03:37 • by Magic Duck
46859 in reply to 46858

Anonymous:
They seem to have removed the "Last Updated" part. It's now only stating the date, which imho is an important piece of information that can come in quite handy.


Exactly. Taking a look into computer's own clock is so awkward. That's why I don't do that but surf to their site to see the time. It's also more reliable as you never know what time the server might have.

Re: Automatic Updates

2005-10-14 04:12 • by seebs
Ironically, we can't tell when this code was written, because the "last updated" information is buggy.

Re: Automatic Updates

2005-10-14 04:18 • by csrster
I love it. A DailyWTF with an actual punchline.

Re: Automatic Updates

2005-10-14 04:55 • by Nand
46863 in reply to 46838
if(dayName==1) Day = "Sunday";
if(dayName==2) Day = "Monday";
if(dayName==3) Day = "Tuesday";
if(dayName==4) Day = "Wednesday";
if(dayName==5) Day = "Thursday";
if(dayName==6) Day = "Friday";
if(dayName==7) Day = "Saturday";

if(monthName==1) Month="Jan.";
if(monthName==2) Month="Feb.";
if(monthName==3) Month="Mar.";
if(monthName==4) Month="Apr.";
if(monthName==5) Month="May";
if(monthName==6) Month="Jun.";
if(monthName==7) Month="Jul.";
if(monthName==8) Month="Aug.";
if(monthName==9) Month="Sept.";
if(monthName==10) Month="Oct.";
if(monthName==11) Month="Nov.";
if(monthName==12) Month="Dec.";


<sarcasm>The horrible if/switchery is needed because the author must make sure dates are always displayed in english, and not possibly some locale that uses different month names!</sarcasm>

Re: Automatic Updates

2005-10-14 06:16 • by Oli

That's just downright dirty. I can forgive the bad code, but the real WTF HAS to be the fact that they're lying to their customers about how often the site is updated. They could have at least been sneaky about it by writing it via some server-side code...


I can just image some fatcat in the company saying "I want it to look like we update our site every day!" and then forcing the hapless intern web developer who's on £4/hr to write the arocity.

Re: Automatic Updates

2005-10-14 08:59 • by Nitboy
46869 in reply to 46804

Manni:
Maybe there's an action item on someone's list that states every January 1st someone needs to edit this document to update the year. Or better yet, someone calls this "developer" every year to say "Oh no! The website is showing LAST YEAR'S DATE!!! Can you help us!?"  "Yep, I sure can. It will cost $2,000 to fix this bug. See you next year."


2000$


My firm would use perhaps 200 man hours fixing this...


So 2000$ would be quite cheap..

Re: Automatic Updates

2005-10-14 09:58 • by RevMike
46874 in reply to 46851
Meh:
'20' + Date.getYear will either display '2004' or '20104' depending on the browser.



Paul O:
Shouldn't someone have commented by now that this looks like a great opportunity to use regex? :)




I'll bite.  They could use something like this
"s/^(\d{2})\d{0,1}(\d{2})$/\1\2/" to fix it.  I, for one, vote for
doing a mod 100 on the result of getYear before prepending the
20.  Let the Y3K people fix it.



Note to Nitpickers:  I stay away from front ends of all kinds, and
with good reason.  I'm guessing that most browsers don't have a
decent regex engine available for scripting.  While I'd be
surprised if there was no mod expression, I'm not sure what format it
would take.

Re: Automatic Updates

2005-10-14 10:17 • by Andr&#233;s Villanueva
It would be funny to enter the site on a february 29th, but we won't have one of those till 2008, and they'll probably fix that by then ;)

Re: Automatic Updates

2005-10-14 10:23 • by emptyset
46878 in reply to 46831

Anonymous:
One of my students refered me to this site.[*]  It reminds me of a 1983 saying: Opus says "Don't look for logic." After 20 yrs in industry as a SE I thought I had seen it all...Hauser, PhD.  see www.nku.edu/~hauserj for a good review.  By the way .... building stuff is more fun; less rewarding.


what...is going on in that site?

« PrevPage 1 | Page 2Next »

Add Comment