<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Zendcasts Forum / static or non-static funtions?]]></title>
		<link>http://www.zendcasts.com/forum/viewtopic.php?id=200</link>
		<description><![CDATA[The most recent posts in static or non-static funtions?.]]></description>
		<lastBuildDate>Tue, 15 Jun 2010 00:50:42 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: static or non-static funtions?]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=898#p898</link>
			<description><![CDATA[<p>Hey Harri,</p><p>Static methods are generally considered evil in the world of OOP since they are essentially namespaced functions, however they do have a place in certain use cases. For example, when you&#039;re building a simple application with only one database connection for your models, a static method for User::FindAll(); makes plenty of sense and reads well.</p><p>The alternative would be some sort of dependency injection like</p><p>$u = new User($conn);<br />foreach($u-&gt;findAll() as $user)<br />{<br /> // iterate here...<br />}<br />this would obviously get cumbersome and repetitive. Also, static methods are parsed more efficiently by the parser.</p><p>my 2 cents...</p>]]></description>
			<author><![CDATA[dummy@example.com (Jon Lebensold)]]></author>
			<pubDate>Tue, 15 Jun 2010 00:50:42 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=898#p898</guid>
		</item>
		<item>
			<title><![CDATA[static or non-static funtions?]]></title>
			<link>http://www.zendcasts.com/forum/viewtopic.php?pid=879#p879</link>
			<description><![CDATA[<p>I&#039;m new to OOP PHP. I have learn OOP, but with Java. The basics are the same but some things are different. </p><p>I see that Jon uses static methods in his examples and Doctrine have some as well. What I am wondering about is which functions should be static and which should not? Should most of them be non-static? What are the best practices and/or the theory behind it?</p><p>I have an example:<br />In my User class extending BaseUser (we are talking Doctrine here). When I&#039;m making a function to get a spesific user by id, what would be the best here? static or not?</p><p>I guess i need to understand in which situation to use static functions and which not to use them. </p><br /><p>I realise that this is not php spesific, but I haven&#039;t encountered this question the little time I have used java.</p>]]></description>
			<author><![CDATA[dummy@example.com (harri)]]></author>
			<pubDate>Thu, 03 Jun 2010 16:04:34 +0000</pubDate>
			<guid>http://www.zendcasts.com/forum/viewtopic.php?pid=879#p879</guid>
		</item>
	</channel>
</rss>

