Thursday, June 28, 2012

Re: Routes vs Type checking for Action Parameters, best practice?

"I think you're not using routes in their purest form (to route stuff in the right way - rather than error trapping". 

Thing is, if you haven't supplied an integer, then there's really no matching action for the URL you've requested. I think that's completely in line with the purpose of routes. 

That is, if you supply a non-integer, then you haven't really matched any existing action, so you're redirected to an error or a default page.

Since PHP doesn't really have strict typing, maybe I could settle for "if you haven't passed the right number of parameters, there's no matching action".

"Why do that in two places?"

I think it could result in cleaner code since you can be sure of the type and amount of input you receive in each action.

Don't you agree?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: