4daab98b010e3
From Joomla! Documentation
Revision as of 04:57, 17 April 2011 by Chris Davenport (talk | contribs) (CodeExample provided by Chris Davenport)
Revision as of 04:57, 17 April 2011 by Chris Davenport (talk | contribs) (CodeExample provided by Chris Davenport)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Let's say, we want to integrate Error-Handling in our application, but we don't know yet, if we want the error to be display, logged in a file, stored to the database, or all of the above. Our goal is, to keep the object that raises the error independent of the objects that store the error message.
What happened here? We separated the functionality of raising an error of the functionality of handling an error. In the future you can add additional ErrorHandlers, or remove some of the existing handlers, without the need to change any classes at all. Furthermore you can simply change an Errorhandler, without the need to change the MyError class. This greatly increases the reusability of your code.
This example was originally contributed by Batch1211.