<?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/"
		>
<channel>
	<title>Comments on: Grouping of constants</title>
	<atom:link href="http://cakebaker.42dh.com/2008/10/09/grouping-of-constants/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2008/10/09/grouping-of-constants/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 31 Jan 2012 15:12:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Grouping &#8220;constants&#8221; with JavaScript - cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/10/09/grouping-of-constants/comment-page-1/#comment-167871</link>
		<dc:creator>Grouping &#8220;constants&#8221; with JavaScript - cakebaker</dc:creator>
		<pubDate>Wed, 14 Jul 2010 14:10:37 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=882#comment-167871</guid>
		<description>[...] while ago I wrote about how you can group related constants in PHP5 by using a constants [...]</description>
		<content:encoded><![CDATA[<p>[...] while ago I wrote about how you can group related constants in PHP5 by using a constants [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/10/09/grouping-of-constants/comment-page-1/#comment-110146</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 14 Oct 2008 14:56:55 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=882#comment-110146</guid>
		<description>@Rafael: Yes, that&#039;s an option which will become interesting in the future. But as you say, it is currently experimental stuff...</description>
		<content:encoded><![CDATA[<p>@Rafael: Yes, that&#8217;s an option which will become interesting in the future. But as you say, it is currently experimental stuff&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rafaelbandeira3</title>
		<link>http://cakebaker.42dh.com/2008/10/09/grouping-of-constants/comment-page-1/#comment-110028</link>
		<dc:creator>rafaelbandeira3</dc:creator>
		<pubDate>Mon, 13 Oct 2008 15:03:53 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=882#comment-110028</guid>
		<description>Nice idea. As of php 5.3 one can use namespaces too - but be aware that it&#039;s still an experimental extension</description>
		<content:encoded><![CDATA[<p>Nice idea. As of php 5.3 one can use namespaces too &#8211; but be aware that it&#8217;s still an experimental extension</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/10/09/grouping-of-constants/comment-page-1/#comment-110026</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Mon, 13 Oct 2008 14:55:04 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=882#comment-110026</guid>
		<description>@charlie: Thanks for your comment!

I don&#039;t know if it is a best practice, but it is the solution you get if you model a configuration file as an object. 

A different approach is to see the configuration as a data container storing key/value pairs, so there is a record for each setting in the table.

In the end it depends on the situation (and your preferences). The first approach is better suited if there are only few settings, whereas the second approach is better if you have many configuration settings.

Hope that helps!</description>
		<content:encoded><![CDATA[<p>@charlie: Thanks for your comment!</p>
<p>I don&#8217;t know if it is a best practice, but it is the solution you get if you model a configuration file as an object. </p>
<p>A different approach is to see the configuration as a data container storing key/value pairs, so there is a record for each setting in the table.</p>
<p>In the end it depends on the situation (and your preferences). The first approach is better suited if there are only few settings, whereas the second approach is better if you have many configuration settings.</p>
<p>Hope that helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: charlie</title>
		<link>http://cakebaker.42dh.com/2008/10/09/grouping-of-constants/comment-page-1/#comment-109967</link>
		<dc:creator>charlie</dc:creator>
		<pubDate>Mon, 13 Oct 2008 02:38:45 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=882#comment-109967</guid>
		<description>And what about settings? things you want the admins be able to change without having to go to the source code and change it there.

Should this be made in the database? I&#039;ve seen CMS like Wordpress and Drupal store settings in a table, so there&#039;s a whole table for just one record with the settings which seems like it&#039;s too much. Is that the best practice for settings?</description>
		<content:encoded><![CDATA[<p>And what about settings? things you want the admins be able to change without having to go to the source code and change it there.</p>
<p>Should this be made in the database? I&#8217;ve seen CMS like WordPress and Drupal store settings in a table, so there&#8217;s a whole table for just one record with the settings which seems like it&#8217;s too much. Is that the best practice for settings?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/10/09/grouping-of-constants/comment-page-1/#comment-109838</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Sat, 11 Oct 2008 08:29:36 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=882#comment-109838</guid>
		<description>@Juan, Hannibal Lecter: Thanks for your comments!

@Juan: I didn&#039;t mean you should always use this approach ;-)  It really depends on your use case, sometimes it makes sense, sometimes it is better to use &quot;define&quot;s or the Configure class. To find the right approach, you have to know the possible approaches...</description>
		<content:encoded><![CDATA[<p>@Juan, Hannibal Lecter: Thanks for your comments!</p>
<p>@Juan: I didn&#8217;t mean you should always use this approach ;-)  It really depends on your use case, sometimes it makes sense, sometimes it is better to use &#8220;define&#8221;s or the Configure class. To find the right approach, you have to know the possible approaches&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dr. Hannibal Lecter</title>
		<link>http://cakebaker.42dh.com/2008/10/09/grouping-of-constants/comment-page-1/#comment-109785</link>
		<dc:creator>dr. Hannibal Lecter</dc:creator>
		<pubDate>Fri, 10 Oct 2008 19:14:24 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=882#comment-109785</guid>
		<description>I have used this system in multiple projects (at work and home), and it is much more logical/descriptive than the regular defines.

Recommended!</description>
		<content:encoded><![CDATA[<p>I have used this system in multiple projects (at work and home), and it is much more logical/descriptive than the regular defines.</p>
<p>Recommended!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Juan Basso</title>
		<link>http://cakebaker.42dh.com/2008/10/09/grouping-of-constants/comment-page-1/#comment-109769</link>
		<dc:creator>Juan Basso</dc:creator>
		<pubDate>Fri, 10 Oct 2008 16:43:08 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=882#comment-109769</guid>
		<description>If have multiples classes, maybe a class for constants is great. But if a define is for some configuration or something like this, is great use Configure class.

In benchmark 3 reads is 0.00013 seconds slower than class. 0.00004 slower than class is acceptable to make a configuration with Configure class and in cake&#039;s style.</description>
		<content:encoded><![CDATA[<p>If have multiples classes, maybe a class for constants is great. But if a define is for some configuration or something like this, is great use Configure class.</p>
<p>In benchmark 3 reads is 0.00013 seconds slower than class. 0.00004 slower than class is acceptable to make a configuration with Configure class and in cake&#8217;s style.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/10/09/grouping-of-constants/comment-page-1/#comment-109768</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Fri, 10 Oct 2008 16:17:19 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=882#comment-109768</guid>
		<description>@all: Thanks for your comments!

@Christian: Well, it depends on the situation ;-)  If you have multiple classes using the same constants, to which class do you add those constants? On the other hand, if the constants are used by only one class it makes sense to add them to that class. 

@José: The Configure class is great to store configuration data. But for &quot;real&quot; constants, i.e. values you cannot change, I prefer to use the respective language construct, hence the use of &quot;const&quot;.

@ajmacaro: See David&#039;s comment, it seems like class constants are slightly slower than &quot;normal&quot; constants.

@David: Hm, I don&#039;t see why you would want to use the Configure class to create class constants. To me it seems like an unnecessary indirection ;-)

And thanks for your benchmark!</description>
		<content:encoded><![CDATA[<p>@all: Thanks for your comments!</p>
<p>@Christian: Well, it depends on the situation ;-)  If you have multiple classes using the same constants, to which class do you add those constants? On the other hand, if the constants are used by only one class it makes sense to add them to that class. </p>
<p>@José: The Configure class is great to store configuration data. But for &#8220;real&#8221; constants, i.e. values you cannot change, I prefer to use the respective language construct, hence the use of &#8220;const&#8221;.</p>
<p>@ajmacaro: See David&#8217;s comment, it seems like class constants are slightly slower than &#8220;normal&#8221; constants.</p>
<p>@David: Hm, I don&#8217;t see why you would want to use the Configure class to create class constants. To me it seems like an unnecessary indirection ;-)</p>
<p>And thanks for your benchmark!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Persson</title>
		<link>http://cakebaker.42dh.com/2008/10/09/grouping-of-constants/comment-page-1/#comment-109755</link>
		<dc:creator>David Persson</dc:creator>
		<pubDate>Fri, 10 Oct 2008 14:17:52 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=882#comment-109755</guid>
		<description>Sorry I&#039;m very bad in making benchmarks...

Each result is the *average* time in *seconds* it requires to read 3 values.

My environment is:
PHP: PHP 5.2.6-pl6-gentoo 
OS: Linux 2.6.25-gentoo-r7 
CPU: i686 Intel(R) Celeron(R) M processor 1.50GHz GenuineIntel
MemTotal:       904140 kB
CakePHP:  1.2.0.7692 RC3</description>
		<content:encoded><![CDATA[<p>Sorry I&#8217;m very bad in making benchmarks&#8230;</p>
<p>Each result is the *average* time in *seconds* it requires to read 3 values.</p>
<p>My environment is:<br />
PHP: PHP 5.2.6-pl6-gentoo<br />
OS: Linux 2.6.25-gentoo-r7<br />
CPU: i686 Intel(R) Celeron(R) M processor 1.50GHz GenuineIntel<br />
MemTotal:       904140 kB<br />
CakePHP:  1.2.0.7692 RC3</p>
]]></content:encoded>
	</item>
</channel>
</rss>

