Re: Re: Insult my code!
| From: | Eric Bauman | Date: | Tue, 13 Oct 2009 04:24:05 +0000 |
| Subject: | Re: Re: Insult my code! | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-298876@lists.php.net to get a copy of this message | ||
On 12/10/2009 9:21 PM, David Otton wrote:
2009/10/11 Eric Bauman<baumane@livejournal.dk>:*sigh* sometimes I really wish PHP allowed one to be a bit more heavy-handed with types (optional real type hinting would be nice). I guess I only ever worried about string (from DB) and int (internal call) as in my specific use I would never be passing a float. You make an excellent point however; I suppose in the interests of completeness, forward compatibility etc. I should take into account more possibilities. Perhaps I should just throw an exception in deposit() etc. if the argument isn't int and worry about converting elsewhere. Also thanks for the sample TestCase code! I've never really thought about unit testing in PHP, despite doing so in Java etc. Reading about PHPUnit brought me on to phpUnderControl - interesting stuff! Best regards, EricAs before, please feel free to insult my code. ;-) Any and all feedback is of course most appreciated.I know you're more concerned with structure, but your checkInt() method is arguably buggy/has an un-noted assumption. It accepts ints formatted as ints and strings, but not floats: