PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Sep 20, 2019 10:45 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sun Oct 17, 2010 6:41 am 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida


Top
 Profile  
 
PostPosted: Sun Oct 17, 2010 11:21 am 
Offline
DevNet Master
User avatar

Joined: Thu Mar 15, 2007 6:28 pm
Posts: 2765
Location: Redding, California


Top
 Profile  
 
PostPosted: Sun Oct 17, 2010 12:53 pm 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida


Top
 Profile  
 
PostPosted: Mon Oct 18, 2010 11:37 am 
Offline
DevNet Master
User avatar

Joined: Thu Mar 15, 2007 6:28 pm
Posts: 2765
Location: Redding, California


Top
 Profile  
 
PostPosted: Mon Oct 18, 2010 12:16 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US

_________________
(#10850)


Top
 Profile  
 
PostPosted: Mon Oct 18, 2010 12:23 pm 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida
There's really too many benefits to list in one spot. One of those is your have full awareness & control over your code's dependencies. If it runs in a unit test, it runs elsewhere. In test last, you can end up with code that has lots of dependencies to where the test is too hard to write it later on.

Also understand code coverage (Ex. 60% of my code executes under a test) is a meaningless figure, because even though a line may be hit, that doesn't imply you hit it with all possible inputs, so TDD helps conceptually 'see' all the tests we're going to need. All my code coverage analysis happens in my head. Because I have good coverage I can re-factor constantly, through small mechanical changes like "extract method" and "inline variable", etc.. my code becomes more like English than 'code' (I'd like to think so).


Top
 Profile  
 
PostPosted: Fri Oct 22, 2010 1:17 am 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida
I fixed an issue with a few test cases that weren't running due to a typo on my part, and fixed corresponding production code. Now passing '2005' properly returns 2005 for both start & end.

Also I added " 2005 - 2006 " as a supported use case, there can be white-space before or after each year and it will be trimmed.


Top
 Profile  
 
PostPosted: Fri Oct 22, 2010 2:56 am 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4313
Location: Sofia, Bulgaria

_________________
There are 10 types of people in this world, those who understand binary and those who don't


Top
 Profile  
 
PostPosted: Fri Oct 22, 2010 12:29 pm 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida
The century threshold is now adjustable for the year/range objects both. See my original post for usage.

I should point out to Jonah Bro if I had implemented caching, I would have had to taken it out now or worry more about what happens if someone changes the threshold after its cached and asks for a value. As you see, caching becomes a complexity in it's own right because any feature we add has to inter-operate with other dependencies in the component. And so far its performing fast enough for me.

However maybe it would have been better to accept all inputs in the constructor and make them immutable, that would be a good way to go if caching becomes necessary in the future.

@Vlad cool but too bad it doesn't handle ranges, or have adjustable thresholds. No idea why they choose '60', 60 wouldn't work well for my users. I bet other people thought the same about my choice of 25, well now you can customize it. Imagine telling someone no products were found for your 2069 Chevy Donk. lol. Or that we have some products for you World War II Jeep made in 2045. I still think my observation is right, 2 digit years tend be used more so during the last century than this one.


Top
 Profile  
 
PostPosted: Fri Oct 22, 2010 12:45 pm 
Offline
DevNet Master
User avatar

Joined: Thu Mar 15, 2007 6:28 pm
Posts: 2765
Location: Redding, California


Top
 Profile  
 
PostPosted: Fri Oct 22, 2010 4:53 pm 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida
Yes but an even broader moral is, get the important stuff working, then worry about the less important stuff, then the slightly less important stuff (this usually goes on ad infinitum if your software is a success).

I have updated with a way to disable Y2K mode, and worked on refactoring the tests some. Updating the OP. Ok done. See y2k-v4.zip

Update 2 - Can now disable Y2k Mode:
Syntax: [ Download ] [ Hide ]
$year->setY2kMode(false);
 


Need to have a way to disable it for a 'year range' (refactoring some of the tests to make this cleaner first). Once that's done I'll probably refactor the production code some, and create an interface or an abstract base class of some sort.


Top
 Profile  
 
PostPosted: Fri Oct 22, 2010 5:25 pm 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida
Everything I just said is now done (v5). The code itself should read a lot more like plain English now.

http://img268.imageshack.us/img268/629/difflx.jpg
http://img101.imageshack.us/img101/8895/diff2.jpg


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group