Constructor (object-oriented programming): Difference between revisions

Content deleted Content added
Coding standards
ColdFusion: Updated to reflect current CF behavior
Line 353:
=== ColdFusion ===
 
[[ColdFusion]] hasuses no constructora method. Developers using it commonly create annamed '<code>init</code>' method that acts as a pseudo-constructor method.
 
<source lang="cfm">
<cfcomponentcomponent displayname="Cheese"> {
<!---// properties --->
property name="cheeseName";
<cfset variables.cheeseName = "" />
 
<!---// pseudo-constructor --->
<cffunction name="init" returntype="Cheese">
function Cheese init( required string cheeseName ) {
<cfargument name="cheeseName" type="string" required="true" />
<cfset variables.cheeseName = arguments.cheeseName />;
<cfreturnreturn this />;
}
</cffunction>
}
</cfcomponent>
</source>