Wednesday 5 October 2011

ColdFusion Icebreaker#1 : Tried CF yet ?


Most of us , if we have something to do with the world wide web,  know the basic concepts of servers...
We know about application servers,web servers...who they are,what they do and when they are used....
Tomcat , Apache , Websphere Appplication Server(popularly called WAS) are common names today.

ColdFusion (CF) is one such server with a huge difference. Its easy !
Easy to install,easy to create powerful applications in and easy to deploy.
You can use the ColdFusion Markup Language  (called CFML) to do pretty much all that you can in any other language, only in fewer lines of code!

The basics are pretty simple : you write .cfm pages(essentially similar to JSP pages) for the view and put your business related code in CFC (ColdFusion components..essentially similar to Java classes)

For instance, lets talk about DB connections . Most developers will/would at least once in their lives have done a DB call, and if Java is what you speak , then it pretty much follows a common algorithm of :

1)Choose the driver
2)Load the driver
3)Get a connection
4)Create handlers to execute your query
5)Run your query
6)Store your results
7)Use your results

Add to that all the necessary exception handling,connection setting, data source setup and what you have is a considerable amount of time spent coding and debugging before the code is good to go.

As of CF 9, thanks to ORM , it is as easy as writing a few tags

1)Setup your data source in the CF Admin data source section.This lets you choose your database from a drop down .All you need to provide are the connection parameters like IP,password etc
2)Provide this datasource name is an Application.cfc file
Eg:   <cfset this.name="MyORMApp"
       <cfset this.ormenabled="TRUE">
       <cfset this.datasource="<your-datasource-name>"
3)Create a cfc that maps to your table (Need not even specify the table name, as long as its the same as the cfc name)
Eg:   <cfcomponent persistent="true">
           <cfproperty name="ROLL NO">
           <cfproperty name="MARKS">
        </cfcomponent>
4)Directly use functions that perform the necessary pull and push of data from the database.
Use this in UI tags like cfgrid
Eg : EntityLoad() = select *

And voila !! you have run a select query without having to bother about the type of driver you used,its syntax and all the related complications.

All this and more..but in less lines of code.

Feel free to try CF..the developer edition is free !







No comments:

Post a Comment