Comment On Last, Last, Last, Last, Last, Last, Last Year

"At my previous job," John S writes, "we had a good amount of formality in the development process. Business 'customers' would define requirements (or bugs), business analysts would write requirements to implement those, and we would write code against the requirements." [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:01 • by Frist? (unregistered)
Frist, frist, frist, etc.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:02 • by Yep (unregistered)
Yep, I was waiting for that

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:03 • by 1234 (unregistered)
What happens if we need $lastlastlastlastlastlastlastlastyear or
$lastlastlastlastlastlastlastlastlastyear or even
$lastlastlastlastlastlastlastlastlastlastyear

luckily we will never need
$lastlastlastlastlastlastlastlastlastlastlastyear ...

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:03 • by highphilosopher (unregistered)
What's so bad with this? Next thing you know people will be complaining about my use of $TheDayBeforeTheFirstMondayOfThisMonthLastYear.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:04 • by Severity One
Whenever I see such a lot of code simply copied, I wonder, have these people ever heard of loops?

Whenever I see such a lot of code simply copied, I wonder, have these people ever heard of loops?

Whenever I see such a lot of code simply copied, I wonder, have these people ever heard of loops?

Whenever I see such a lot of code simply copied, I wonder, have these people ever heard of loops?

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:05 • by me (unregistered)
what are the odds that the probeility of the month being frebruary?

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:10 • by Techpaul (unregistered)
299385 in reply to 299384
by me:
2010-02-17 09:05 • by me
what are the odds that the probeility of the month being frebruary?


Bessy says "Content Blocked"

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:13 • by Richard T. Roll (unregistered)
Totally not a wtf. This is just an optimization so that you can access the previous years by numerical value, like this:

$which = "";

while (year++ != current)
$which .= "last"
echo $${which}year


I've used this a lot in my programming career and I know some might disagree but tbh it's just a different approach.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:14 • by Techpaul (unregistered)
Having seen websites with PHP code where three groups of modules were 99.9% identical, except for the WHERE clause of what to serach the database for, nothing on websites amazes me.

Don't even get me on the inability of some hosting companies, to understand the differences between even Windows and Linux.

Anyway "that was so lastlastlastlastlastyear".

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:15 • by Tim (unregistered)
ah, a good old fashioned 100% bad code indefensible WTF (and using PHP into the bargain)

this is what we like to see

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:17 • by Dascandy (unregistered)
Imagine the code for the date-of-birth field...

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:17 • by akatherder
Optimize!


<?php
$thisyear=date("Y");
$lastyear=$thisyear-1;
$lastlastyear=$lastyear-1;
$lastlastlastyear=$lastlastyear-1;
$lastlastlastlastyear=$lastlastlastyear-1;
$lastlastlastlastlastyear=$lastlastlastlastyear-1;
$lastlastlastlastlastlastyear=$lastlastlastlastlastyear-1;
$lastlastlastlastlastlastlastyear=$lastlastlastlastlastlastyear-1;
?>

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:19 • by frits
Geez, don't they realize the numberline goes in two directions?

<?php
$thisyear=date("Y");
$lastyear=date("Y")-1;
$lastlastyear=date("Y")-2;
$lastlastlastyear=date("Y")-3;
$lastlastlastlastyear=date("Y")-4;
$lastlastlastlastlastyear=date("Y")-5;
$lastlastlastlastlastlastyear=date("Y")-6;
$lastlastlastlastlastlastlastyear=date("Y")-7;
$nextyear=date("Y")+1;
$nextnextyear=date("Y")+2;
$nextnextnextyear=date("Y")+3;
$nextnextnextnextyear=date("Y")+4;
$nextnextnextnextnextyear=date("Y")+5;
$nextnextnextnextnextnextyear=date("Y")+6;
$nextnextnextnextnextnextnextyear=date("Y")+7;
?>


Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:23 • by Appellles (unregistered)
Shoemaker, stick to your $last.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:24 • by NMe
I wonder what would happen if they set error_reporting to report E_NOTICE as well...

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:25 • by jonsjava
I decided to improve the code to a degree:

<?php
$thisyear=date("Y");
$math = round((($thisyear * 2) + 4) /2 - 2);
$lastyear=round((($math * 4) + 4) / 4 - 2);
$lastlastyear=round((($math * 6) + 4) / 6 - 2);
$lastlastlastyear=round((($math * 8) + 4) / 8 - 3);
?>

You see, you grab a random equation, and apply it randomly across the board, and you get the same results, while having crazy code. Job Security.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:26 • by me_again (unregistered)
299398 in reply to 299390
Dascandy:
Imagine the code for the date-of-birth field...

+1


captcha: enim -> Eminems little brother

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:30 • by Anon (unregistered)
299399 in reply to 299398
Could have been worse:

$year2008 = 2008;
$year2007 = 2007;
$year2006 = 2006;
etc.

I mean, this is php after all.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:35 • by jonsjava
299400 in reply to 299399
Anon:
...
I mean, this is php after all.


PHP isn't a bad scripting language. It's just that 99% of the PHP coders give the rest of us a bad name. I use it for server-side coding (both windows/linux) when I need a script to do something, and I don't have the time to build a real app. Handy little system in a pinch.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:35 • by operagost
299401 in reply to 299384
me:
what are the odds that the probeility of the month being frebruary?

The frobbitz on the jim slam blempglorf bandersnatch!

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:37 • by Salami
299403 in reply to 299399
Anon:
Could have been worse:

$year2008 = 2008;
$year2007 = 2007;
$year2006 = 2006;
etc.

I mean, this is php after all.


Or

$year = 2010;
$yearlast = 2009;
$yearlastlast = 2008;
etc

with an optional comment saying "TO DO: Changes years on Jan 1st"

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:43 • by M.C. (unregistered)
LastYearToInfinity...

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:45 • by Jared (unregistered)
That'll fail on a leap year. ;-)

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:48 • by grizz (unregistered)
299409 in reply to 299386
Richard T. Roll:

I've used this a lot in my programming career and I know some might disagree but tbh it's just a different approach.


I've used cannibalism a lot in my food-procuring career and I know some might disagree but tbh it's just a different approach.

Sometimes "bad" really is bad, not just different.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:49 • by raluth (unregistered)
Pah; this story is just so date("Y")-1

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:51 • by toth
Well, on embedded systems like Bessy, it's much more efficient to unroll the loop. Paula Bean taught me that.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:54 • by APK (unregistered)
TRWTF is the lack of underscores. It should be "$last_last_last_last_year" which is much more readable and maintainable.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 09:55 • by Voodoo Coder
What REALLY surprises me is that PHP doesn't have a built-in method for this year minus seven.

I suppose it'll be in the next release...

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 10:01 • by Bob (unregistered)
299414 in reply to 299386
Applause!

Birthday

2010-02-17 10:03 • by PHPGangsta (unregistered)
Last week I wrote code to display a drop-down-field for birthday, with the last 120 years (1890-2010). That was done with a few (~5 or so) lines of code.

Would be interesting to see this in your notation. Great code example!

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 10:04 • by silent d (unregistered)
I want to hear more about the OP's previous job, where business analysts wrote requirements to implement bugs.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 10:05 • by Bob (unregistered)
299417 in reply to 299413
strtotime("-7 years") is pretty close.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 10:08 • by Dirk (unregistered)
Last post.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 10:08 • by Dirk (unregistered)
Last last post.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 10:09 • by Dirk (unregistered)
OK I'll stop now.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 10:11 • by Slink (unregistered)
299422 in reply to 299409
grizz:
Richard T. Roll:

I've used this a lot in my programming career and I know some might disagree but tbh it's just a different approach.


I've used cannibalism a lot in my food-procuring career and I know some might disagree but tbh it's just a different approach.

Sometimes "bad" really is bad, not just different.


You were writing that as a reply to a post made by Richard T.Roll... Sarcasm detector offline? ;) Or am I the one missing that sarcasm tag in your reply?

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 10:21 • by Manniakk (unregistered)
$TheDayBeforeTheFirstMondayOfThisMonthLastYear = "Sunday";

sooo simple :D

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 10:25 • by NightDweller
299424 in reply to 299400
jonsjava:
Anon:
...
I mean, this is php after all.


PHP isn't a bad scripting language. It's just that 99% of the PHP coders give the rest of us a bad name. I use it for server-side coding (both windows/linux) when I need a script to do something, and I don't have the time to build a real app. Handy little system in a pinch.


Whenever i look at stats like "99% of php code is crap" i wonder - is it that 99% of the PHP programmers are crap, or that all php programmer are crappy 99% of the time?

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 10:28 • by Cbuttius
ThisYear - 7 is not allowed as 7 is a magic number.

LastLastLastLastLastLastLastYear is much better.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 10:29 • by kftt (unregistered)
299426 in reply to 299384
me:
what are the odds that the probeility of the month being frebruary?

smarch

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 10:58 • by java.lang.Chris;
299429 in reply to 299400
jonsjava:
PHP isn't a bad scripting language.


Yes it is. PHP is poorly designed and inconsistent. The most popular implementation is also a mess and unlikely to get better - one of the leading guys working on improving the stability and security of the code quit in disgust at the unwillingness of Zend to accept changes.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 11:05 • by 1234 (unregistered)
299430 in reply to 299421
Dirk:
OK I'll stop now.


Thank you.

Re: Birthday

2010-02-17 11:05 • by Marius (unregistered)
299431 in reply to 299415
And did you have any 120 years old visitors on that site?
I'm curious.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 11:07 • by aBase (unregistered)
299432 in reply to 299400
jonsjava:
It's just that 99% of the PHP coders give the rest of us a bad name.
Yeah, they're the ones who go around saying things like "99% of..."

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 11:09 • by MetalPig
299433 in reply to 299411
toth:
Paula Bean taught me that.

Isn't she on the same network as Rachael Array?

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 11:10 • by Dascandy (unregistered)
299434 in reply to 299425
That's a comment that's so rational yet so wrong that my stomach contracted. I can imagine that actually being brought forward by somebody.

That somebody wouldn't be my colleague for long, one way or another.

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 11:11 • by drive-by proofreader (unregistered)
"When I took a new job at a small company, I knew the processes WOULD be a little more 'casual', but I never quite expected this. Even the code is written casually, avoiding unnecessary formalities like arrays and loops."

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 11:16 • by Enterprise Architect (unregistered)
299436 in reply to 299429
java.lang.Chris;:
PHP is poorly designed and inconsistent. The most popular implementation is also a mess and unlikely to get better - one of the leading guys working on improving the stability and security of the code quit in disgust at the unwillingness of Zend to accept changes.
Aaah… the wonders of open source.

http://qdb.us/301603

To Akismet: Who spams by posting links to QDB?

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 11:26 • by forgottenlord (unregistered)
When I took a new job at a small company, I knew the processes wouldn't be a little more 'casual', but I never quite expected this. Even the code is written casually,


"Wouldn't be a little more 'casual'? But then....how is the code casual if it wouldn't be more casual? </pedantic-bastard>

Re: Last, Last, Last, Last, Last, Last, Last Year

2010-02-17 11:28 • by Coyne
Those names are going to get totally unwieldy after a while, because of their length. The programmer should have gone with:

$thisyear=date("Y");

$lastyear=date("Y")-1;
$theyearbeforelastyear=date("Y")-2;
$the2ndyearbeforelastyear=date("Y")-3;
$the3rdyearbeforelastyear=date("Y")-4;
$the4thyearbeforelastyear=date("Y")-5;
$the5thyearbeforelastyear=date("Y")-6;
$the6thyearbeforelastyear=date("Y")-7;
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment