Jeśli jesteś właścicielem tej strony, możesz wyłączyć reklamę poniżej zmieniając pakiet na PRO lub VIP w panelu naszego hostingu już od 4zł!

Play nice when extending Exception

Play nice when extending Exception

Lukas Smith has a suggestion for developers out there who get the idea to start messing with the order of the parameters of PHP objects/methods – play nice. His example is specifically with Exceptions.

This is just a short follow up to a recent tweet of mine. I have seen this repeatedly happen, even to top notch and usually very careful developers (*). I am not sure why this mistake happens so frequently, but quite often you see code that changes the parameter order for custom Exception constructors. I guess it’s mostly because in these cases the developer wants to pass some magic parameters that contain the message (and potentially also the code).

He recommends that, if you really do need to change something like the order of the parameters, use something like a factory to handle the reorganization for you.

Source: http://www.phpdeveloper.org/news/16397

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Posted Maj 30th, 2011 in WEB and PHP Development.

Leave a response: