Skip to main content

Posts

Showing posts with the label coldfusion component

Object Oriented Programming in Coldfusion using components

Object Oriented programming is one of the famous programming techniques that reduces code redundancy and encourages code re-usability through a methodology called inheritance. Cold fusion has its own way to implement Object Oriented using components. Components in Coldfusion are equivalent the classes in Java. In this tutorial I will try to demonstrate the construction and usage of components in coldfusion. The first step is to create a directory under your web root normally wwwroot called (classes or components or any other name you like to call the physical repository of your components) Follow the example on the Mode component (class) If you have any question please don't hesitate to comment.

Mode Component (class) in Coldfusion

In statistics, the mode is the value that occurs the most frequently in a data set or a probability distribution. In some fields, notably education, sample data are often called scores, and the sample mode is known as the modal score. [1] The code below will find the mode value in a non sorted array. Save the below component with the name mode.cfc in a directory under wwwroot, in my case I save my components in a directory called classes: <cfcomponent> <cffunction name="getMode" access="public" returntype="string"> <cfargument name="amode" type="array" required="true"> <cfset oldcount=0><cfset oldtemp=0> <cfloop from="1" to="#arrayLen(amode)-1#" index="i"> <cfset temp=amode[i]> <cfset count=1> <cfloop from="#i+1#" to="#arrayLen(amode)-1#" index="j"> <cfif temp i...