<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:series="http://organizeseries.com/"
		>
<channel>
	<title>Comments on: Exceptional PHP: Extending The Base Exception Class</title>
	<atom:link href="http://www.brandonsavage.net/exceptional-php-extending-the-base-exception-class/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brandonsavage.net/exceptional-php-extending-the-base-exception-class/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=exceptional-php-extending-the-base-exception-class</link>
	<description>The personal blog of Brandon Savage. Contains entries of a personal and professional nature focusing on PHP, Apple, LAMP, MySQL and Washington, DC.</description>
	<lastBuildDate>Wed, 15 May 2013 14:54:51 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.2-alpha</generator>
	<item>
		<title>By: Michael Kimsal</title>
		<link>http://www.brandonsavage.net/exceptional-php-extending-the-base-exception-class/#comment-2142</link>
		<dc:creator>Michael Kimsal</dc:creator>
		<pubDate>Thu, 19 Nov 2009 02:21:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=993#comment-2142</guid>
		<description><![CDATA[re: getters and setters, it&#039;s something that can be hidden in other languages, but can&#039;t be in PHP, and probably won&#039;t be any time soon (or perhaps never).

What would be truly useful is to have generic get/set methods automatically created at compilation time, and any references to retrieving or setting values would always look for the appropriate getter or setter.  Since they&#039;d be automatically added at compile time, they&#039;d always be there.  For the times that you&#039;d want to modify the behaviour, simply write a getter or setter with the customer behaviour and it would override (or obviate?) the default one that the PHP compiler would normally generate.

This would allow for much more succint code to be written - loads of boilerplate code would be avoided, and there&#039;d be no need to have to refactor calls to properties to explicity use get/set methods - it&#039;d be transparent.  Less code, standardized behaviour, what&#039;s not to love?  (yeah yeah, some extra work at runtime - code caching would solve the bulk of that issue).]]></description>
		<content:encoded><![CDATA[<p>re: getters and setters, it&#8217;s something that can be hidden in other languages, but can&#8217;t be in PHP, and probably won&#8217;t be any time soon (or perhaps never).</p>
<p>What would be truly useful is to have generic get/set methods automatically created at compilation time, and any references to retrieving or setting values would always look for the appropriate getter or setter.  Since they&#8217;d be automatically added at compile time, they&#8217;d always be there.  For the times that you&#8217;d want to modify the behaviour, simply write a getter or setter with the customer behaviour and it would override (or obviate?) the default one that the PHP compiler would normally generate.</p>
<p>This would allow for much more succint code to be written &#8211; loads of boilerplate code would be avoided, and there&#8217;d be no need to have to refactor calls to properties to explicity use get/set methods &#8211; it&#8217;d be transparent.  Less code, standardized behaviour, what&#8217;s not to love?  (yeah yeah, some extra work at runtime &#8211; code caching would solve the bulk of that issue).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/exceptional-php-extending-the-base-exception-class/#comment-2076</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Sat, 14 Nov 2009 13:17:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=993#comment-2076</guid>
		<description><![CDATA[Dave, I hope I responded to your concern with the third blog post in the series about nesting exceptions.

Jon, I think you completely missed the point of this article. Most exceptions (look at Zend Framework) don&#039;t actually implement new functionality; they simply extend the existing exceptions so that you know which library threw the exception.

As for the getter and setter method, this is a tried-and-true programming strategy, and though you may disagree with it, that&#039;s your choice. Lots of people choose to use it, and I&#039;m one of those people; it&#039;s not an inappropriate or incorrect way of doing things, just a different one from perhaps how you would do it.]]></description>
		<content:encoded><![CDATA[<p>Dave, I hope I responded to your concern with the third blog post in the series about nesting exceptions.</p>
<p>Jon, I think you completely missed the point of this article. Most exceptions (look at Zend Framework) don&#8217;t actually implement new functionality; they simply extend the existing exceptions so that you know which library threw the exception.</p>
<p>As for the getter and setter method, this is a tried-and-true programming strategy, and though you may disagree with it, that&#8217;s your choice. Lots of people choose to use it, and I&#8217;m one of those people; it&#8217;s not an inappropriate or incorrect way of doing things, just a different one from perhaps how you would do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.brandonsavage.net/exceptional-php-extending-the-base-exception-class/#comment-2017</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Wed, 11 Nov 2009 17:26:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=993#comment-2017</guid>
		<description><![CDATA[I&#039;m not 100% sure you&#039;ve actually explained *why* it&#039;s a good idea that each layer has its own exception type.

You seem to be saying by not handling and rethrowing you *don&#039;t* know where where the exception was raised. Surely the opposite is true? If you don&#039;t handle and rethrow you know *exactly* where the original exception was raised without it being dressed up in layers of other exceptions that were triggered as the problem bubbles up through the layers.

You&#039;ve also said &quot;it is impossible for us to ensure that we have properly abstracted our application&quot; which I&#039;m not sure I understand.]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m not 100% sure you&#8217;ve actually explained *why* it&#8217;s a good idea that each layer has its own exception type.</p>
<p>You seem to be saying by not handling and rethrowing you *don&#8217;t* know where where the exception was raised. Surely the opposite is true? If you don&#8217;t handle and rethrow you know *exactly* where the original exception was raised without it being dressed up in layers of other exceptions that were triggered as the problem bubbles up through the layers.</p>
<p>You&#8217;ve also said &#8220;it is impossible for us to ensure that we have properly abstracted our application&#8221; which I&#8217;m not sure I understand.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.brandonsavage.net/exceptional-php-extending-the-base-exception-class/#comment-2016</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Wed, 11 Nov 2009 14:40:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=993#comment-2016</guid>
		<description><![CDATA[I&#039;m not sure I agree with some of the things in this article.  Namely defining a var for the class named $userMessage, then defining a function that all it does it set the message, and then a another function that just calls the variable.

It&#039;s unecessary overhead.  If you want to go this route, why not just make the variable public and define it whenever you want, wherever you want.  Defining a function to sit in memory and wait to be called is not exactly the best idea..

Better though than the above would be just to define $userMessage as an Array(), catching whatever messages (exceptions, whatever), and then using that array to display messages.  I would put it in the destruct() myself and have it report however I wanted.


Also, you said you were extending the Exceptions class to customize it, but you didn&#039;t do any customization at all to the Exceptions class.  Finally, the &quot;final&quot; keyword isn&#039;t suposed to be the same as public/private/protected.  Not to mention that if the Exceptions class was defined as &quot;final&quot;, trying to extend isn&#039;t theoretically suposed to work.

I think you may want to reconsider a lot of the above article as it may be misleading to many...]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure I agree with some of the things in this article.  Namely defining a var for the class named $userMessage, then defining a function that all it does it set the message, and then a another function that just calls the variable.</p>
<p>It&#8217;s unecessary overhead.  If you want to go this route, why not just make the variable public and define it whenever you want, wherever you want.  Defining a function to sit in memory and wait to be called is not exactly the best idea..</p>
<p>Better though than the above would be just to define $userMessage as an Array(), catching whatever messages (exceptions, whatever), and then using that array to display messages.  I would put it in the destruct() myself and have it report however I wanted.</p>
<p>Also, you said you were extending the Exceptions class to customize it, but you didn&#8217;t do any customization at all to the Exceptions class.  Finally, the &#8220;final&#8221; keyword isn&#8217;t suposed to be the same as public/private/protected.  Not to mention that if the Exceptions class was defined as &#8220;final&#8221;, trying to extend isn&#8217;t theoretically suposed to work.</p>
<p>I think you may want to reconsider a lot of the above article as it may be misleading to many&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carlos Aguado</title>
		<link>http://www.brandonsavage.net/exceptional-php-extending-the-base-exception-class/#comment-2015</link>
		<dc:creator>Carlos Aguado</dc:creator>
		<pubDate>Wed, 11 Nov 2009 10:50:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=993#comment-2015</guid>
		<description><![CDATA[Hi Brandon,

Thanks for sharing, good article!

When it comes to logging an exception, I&#039;ve come to find useful to do it in such a way that an unique global application &quot;exception code&quot; is attached to the exception info. Something like this in your app:

try {
  // Do something that can throw a Zend_Xxx_Exception
  }
catch (Zend_Xxx_Exception $e) {
  BasicClass::logException(3001, $e);
  }

Then you log it this way in your BasicClass::logException()
method:

public static function logException($exceptionCode = 0, $exception)
{

    // Do custom exception formatting stuff...

    $exceptionInfo = get_class($exception).&#039; Code &#039; . (int) $exceptionCode . &#039;; Msg: &quot;&#039; . $exception-&gt;getMessage() . &#039;&quot;&#039;;

    $zfLogger-&gt;log($exceptionInfo, Zend_Log::ERR, $exception-&gt;getFile(), $exception-&gt;getLine());
    }
}

This global application exception code approach is used in some big companies and is really useful for later troubleshooting.]]></description>
		<content:encoded><![CDATA[<p>Hi Brandon,</p>
<p>Thanks for sharing, good article!</p>
<p>When it comes to logging an exception, I&#8217;ve come to find useful to do it in such a way that an unique global application &#8220;exception code&#8221; is attached to the exception info. Something like this in your app:</p>
<p>try {<br />
  // Do something that can throw a Zend_Xxx_Exception<br />
  }<br />
catch (Zend_Xxx_Exception $e) {<br />
  BasicClass::logException(3001, $e);<br />
  }</p>
<p>Then you log it this way in your BasicClass::logException()<br />
method:</p>
<p>public static function logException($exceptionCode = 0, $exception)<br />
{</p>
<p>    // Do custom exception formatting stuff&#8230;</p>
<p>    $exceptionInfo = get_class($exception).&#8217; Code &#8216; . (int) $exceptionCode . &#8216;; Msg: &#8220;&#8216; . $exception-&gt;getMessage() . &#8216;&#8221;&#8216;;</p>
<p>    $zfLogger-&gt;log($exceptionInfo, Zend_Log::ERR, $exception-&gt;getFile(), $exception-&gt;getLine());<br />
    }<br />
}</p>
<p>This global application exception code approach is used in some big companies and is really useful for later troubleshooting.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using disk: enhanced (User agent is rejected)
Object Caching 532/550 objects using apc
Content Delivery Network via Amazon Web Services: S3: brandonsavage-net-files.s3.amazonaws.com

 Served from: www.brandonsavage.net @ 2013-05-18 07:51:46 by W3 Total Cache -->