TechiWarehouse.Com

Programming Languages


Computer Training Excuses - No ExcuseYou wouldn't go to a doctor who had never been to medical school, or hire a lawyer who never studied law. One side-effect of a world advancing as rapidly as ours is that fields are becoming more and more specialized and narrow. People can no longer get by on general knowledge in their careers, something I found out for myself not too long ago. I'd been out of high school for two years, scraping by on my own and picking up scraps of programming as I went. I saw all of the self-taught programmers breaking into the IT industry, and I hoped to do the same. After all, IT is one of the few industries out there where being creative and a quick learner is more important than a degree.
Divider Line

Which is the Easiest Programming Language? - Programming LanguagesIf you have some misconception in mind that the programming languages are easy or hard, I am afraid to say that you are mistaken. To tell you frankly about the programming languages, there is nothing such as easy or tough programming language. The only thing that you need to keep in mind while stepping into the world of programming languages is that which programming language would set your base by giving you in-depth knowledge of programming logics and the basics of programming techniques.
Divider Line

ColdFusion Tutorial - ColdFusion TutorialAll you newbies are gonna love this tutorial. It's one of those rare tutorials that actually talk about the history of ColdFusion Programming also. Coldfusion is a tool made from a company called Allaire, which provides a means of database to webserver communications. CFM stands for Coldfusion Management, is the extension most of the files end with. Coldfusion runs on most Windows and Solaris webservers, however it is not standard software that's installed, you will have to request it if its available, and it will cost you a bit more.
Divider Line

Entering into Programming World - Good Luck ProgrammingOnce you have learned some programming languages, you feel yourself completely prepared to enter into the programming world, and start working on the programming languages that you have learned. Many students also feel that they have learned extra things which might be helpful in their programming careers. The matter of fact is that the real world is entirely different from what you have been taught in the classrooms.
Divider Line

Basic Object-Oriented Concepts - Basic Object-Oriented Concepts There is an old story of how several blind men set out to understand what an elephant was by examining a live specimen. Each of them explored a different part of the elephant's body. One blind man, falling against the elephant's side, proclaimed that an elephant must be very much like a wall. Another, grasping the elephant's ear, decided that an elephant must closely resemble a leaf. One grabbed the elephant's tail and determined that elephants must resemble ropes.
Divider Line

Why Programmers Love the Night - Programming at night One famous saying says that programmers are machines that turn caffeine from coffee and Coca Cola into a programming code. And if you ask a programmer when does he like working the most and when is he most productive - he is probably going to say late at night or early in the morning, that is when he has the greatest energy and concentration to work.
Divider Line

How to be a Programmer - Programing training To be a good programmer is difficult and noble. The hardest part of making real a collective vision of a software project is dealing with one's coworkers and customers. Writing computer programs is important and takes great intelligence and skill. But it is really child's play compared to everything else that a good programmer must do to make a software system that succeeds for both the customer and myriad colleagues for whom she is partially responsible. In this essay I attempt to summarize as concisely as possible those things that I wish someone had explained to me when I was twenty-one.
Divider Line

TW Tech Glossary - Misplaced your bible? Well here it is - Tech Glosasary! This truly took a while to complete and should be used by all from beginners to advance techies.
Divider Line

How to Install the Aptana Studio IDE on Windows - Aptana Studio 3IDE (Integrated Development Environment) represents an integrated development environment in which you can develop applications. This tutorial will be useful to all those that considering doing programing...
Divider Line

What Programming Language To Learn - Programming LanguagesOne of the most common questions we hear from individuals hoping to enter the IT industry is, "What programming languages do I need to know?" Obviously this is a complex question, and the answer will depend on what field the questioner is going into. Many programming languages are taught during courses used to obtain a computer information science degree. However, those already in IT know that the greatest skill you can have is to be a jack-of-all-trades. A well-prepared worker can switch between computer programming jobs with only minimal training, thanks to a wide knowledge of multiple programming languages.
Divider Line

What is ColdFusion?

ColdFusion is a rapid application development system for professional developers who want to create dynamic Web applications and interactive Web sites. ColdFusion is an application server from Allaire. It is now more than 3 years old, so it is a bit more mature than many other application servers out there. Version 4 has just been released.

ColdFusion can be installed on Microsoft Windows NT or Sun Solaris, works with several web servers, and can access several different databases (including Oracle, Sybase, Microsoft SQL, Access). It provides the fastest way to integrate browser, server, and database technologies into powerful Web applications. With ColdFusion, you can build everything from online stores to sophisticated business systems.

Developing applications with ColdFusion does not require coding in a traditional programming language like Perl, C/C++, Visual Basic, Java, or Delphi. Instead, you build applications by combining standard HTML with a straightforward server-side markup language, the ColdFusion Markup Language (CFML).


Tips

Proper Comments

BenForta in his book Web Database Construction Kit tells us to use as the format to comment text. It's in the CF3.0 and CF3.1 online documentation too but actually It's three hyphen and not 2! Sounds pretty simple, but when you actually got used to using 2 and too lazy to add another hyphen the problem starts coming.

HTML comment tags for 2 hyphen and without space after and before the tags is fine. My experience with using 2 hyphen caused me to find the problem after several hours of testing the code and removing almost all the CFML tags to locate the culprit. I could not find the problem until I noticed I missed a space after the HTML tags and not on the CF tags I was commenting.

Crazy Color

When you use font colors on a CFML variable name, try to avoid using RGB coding in #RGBas in #FFFFFF for the color white instead use 'White' as in this example or remove the pound sign ) altogether.

#variablename#

Or

#variablename##variablename#

If you are rushing your project, that's good enough. If you'd rather stay with the convention, escape it with the of use double pound sign.

#variablename#

Loop and Populate

When you have a predefined number of groups in a database and you want to populate all the records segregated by groups you might think making different sqls will do the trick. What if you have 8 groups, then you will need to write 8 sqls! Image having 20.

The solution is to use CFLOOP and a dynamically written query name to be referenced in my selection box later. The code is written below.
 

name="ListPolicy#xNumber#"
datasource="File Leaves"
SELECT policy.policycode as code,
policy.PDFFILE as PDFFile,
policy.policy as policyname
FROM policy where 0=0 and policy.policycode='EP' and policy.policycode='WH' and policy.policycode='BW' and policy.policycode='ED' and policy.policycode='SP' and policy.policycode='WR'

Take note of the following:

-The name of the query, ListPolicy#xNumber on the first pass of the loop ListPolicy#xNumber becomes ListPolicy1, then on the next sequence ListPolicy2 until the 6th loop, ListPolicy6.

-CFIF on xNumber, this will assign the first loop or the query ListPolicy1 to the group EP, the next sequence assigns ListPolicy2 to WH and so on.

How does my selection box looks like?

EP



WR

Default CFM?

Most web servers use default.htm or default.html or index.htm or index.html as the path default page. Now, what if you want a CFM file to be the default page but would not want to re-set the default file type setup?

Use JavaScript on the default page to open a CFM file
 

parent.location.href = "default.cfm";

Database Essentials

ColdFusion can be used to access data in virtually any database for which a drivers available and installed on the ColdFusion server. In all cases, ColdFusion primarily provides "wrappers" for database commands written in SQL. Therefore, knowledge of basic SQL programming will be necessary. In many cases, knowledge will be required also of the superset of SQL used with a particular brand of database engine. Oracle and MS Access are two of the database engines commonly used at NIEHS.

URL Encoded Format with no strings attached..

TheURLEncodedFormat() allows web developers to pass spaces and other non-alphanumeric string data in the URL of a page. Without this, only the valid characters would be picked up while the special characters (including spaces) would be dropped. What URLEncodedFormat does is replace the spaces with the"+" sign and the other special characters are replaced with the equivalent hexadecimal escape sequences.

Avoid Problems With Large Verity Collections

ColdFusion includes an implementation of 's popular Search '97 software, letting developers create and search collections of HTML files, most productivity-application documents (, PowerPoint, and so forth), , and even relational databases. Many Web builders, however, encounter problems trying to index large collections of documents with ColdFusion. Follow these three tips to help keep your Verity collections from causing problems:

  1. Keep your collections optimized. The ColdFusion administration interface has an option for optimizing your Verity collections. Use it often. If automation is your game, you can write and schedule a simple CFML template to do the optimizations for you.

     

  2. Consider numerous smaller collections. For example, if your site contains sections for marketing, sales, and products, consider creating a separate Verity collection for each section. Smaller collections are easier to manage, and you'll also be able to narrow searches to specific areas of your site. Your visitors will thank you.

     

  3. Increase memory. Nothing improves the performance of your Web applications more than additional server memory. With memory prices at an all-time low, it is a worthwhile investment.

If you still get errors indexing your files after optimizing your collections, splitting them into several sections, and adding memory to your server, consider purchasing a full-blown copy of Search '97 and creating your collections from that. ColdFusion can search external Verity collections created from the full product as well as from its bundled version of the search engine.

Deal With Undeliverable Email

SMTP mail generated by ColdFusion sits in a Spool directory on the server (usually \CFusion\Mail\Spoolon Windows NT) until it is sent. Mail that fails delivery because of problems connecting to the SMTP server gets converted into a text file and dumped into a directory called Undeliverable (\CFusion\Mail\Undeliverable on Windows NT). You have to manually intervene to resend messages returned to the undeliverable directory. This usually means moving the text files from the Undeliverable directory back to the Spool directory. ColdFusion regularly scans the Spooldirectory for messages to deliver, so the next time the program scans the directory it will attempt to resend the messages.

As you can imagine, checking the undeliverable directory on a regular basis is tedious at best. Luckily, there's a custom CFML tag that automates the task for you. CF_ResendUndeliverableEmail, available as freeware from the , automatically scans the Undeliverable directory for returned mail at scheduled intervals, and then moves any files that it finds to the Spool directory for delivery.

Create Static Pages

While dynamically generated ColdFusion pages have many advantages, they can create server overhead and lead to long download times for your users. Sometimes static HTML pages are good enough, and much faster and less resource-intensive--for example, if you have a series of reports that get generated only once a month, or a set of pages that rarely change.

Fortunately, it's easy to build static pages from CFML templates using the and tags.

First, you need to specify what CFML template to call in the tag:
 

url="http://url.to.your.existing.CFM.template/">

After executes the template, the output is stored in a variable calledCFHTTP.FileContent. The next step is to write the contents of CFHTTP.FileContentto an HTML file on the server:
 

file="YourPathandFileOnServer.html"
output="#CFHTTP.FileContent#">

This writes out the resulting HTML to the path and filename you specify in the file attribute.

Break the ODBC Lock

is one of the most commonly used databases serving as a back-end to ColdFusion applications. Although not particularly well suited to concurrent user applications, Access is a popular choice for development projects because it's cheap and easy to use.

A common scenario when using Access (and other desktop databases such as and ) involves the need to overwrite an existing Access database with an updated version. This is no problem, until you actually attempt to overwrite the Access database. In the default mode, when ColdFusion first accesses a database, it places a lock on the database file so that no other program will attempt to overwrite the database. You can, in the ColdFusion Administrator, configure ColdFusion to drop this lock after each database query. Unfortunately, depending on the ODBC driver, this may or may not work for your particular database. If that's the case, you'll need to find another way to break the ODBC lock when it's time to upload a new version of your database.

Inmost cases you can simply run a query against the database that causes an ODBC error. Create a CFML template that intentionally contains an invalid query (for example, try querying a field that doesn't exist in the database). The error causes ODBC to drop the connection to the database. The downside of this approach is that if someone hits a template that makes a valid call to the database before you upload your updated database, ODBC will try to lock the database that you're trying to overwrite. Making your updates during off-peak hours can minimize the chances of this happening.

A better method is to stop the ColdFusion Application Server and IDE services from the Control Panel (in Windows), upload the new database, and then restart the services. The whole process usually takes less than a minute and minimizes the chance of a bad upload. The downside is that your ColdFusion server must be down while the update is taking place. You can automate the entire process by writing batch file and then scheduling it through a scheduling tool. Again, doing this at off-peak hours is a good idea.

Dynamically Populate Java Applets

One of Cold Fusion's coolest features is its ability to coexist with other technologies, including Java. ColdFusion is an ideal way to populate Java applets with dynamically generated data.

A classic example consists of dynamically populating a Java ticker applet with stock data. The ticker applet, Pros roll 2.3, is available as freeware. Stock data is obtained by a custom CFML tag called CF_StockGrabber. CF_Stockgrabber is also freeware and is available for download from the . The process works by creating a query and then inserting the results of that query into the applet, like so:

Ticker Symbols="CNET,YHOO,MSFT"
QueryName="GetQuotes"
ErrorPage="error.cfm"
ErrorMailTo="webmaster@yourdomain.com">


##yellow###Last_Traded_Time# ##white## - #Symbol# #Last_Traded_Price# Change#) ">

A working demo including source code is available on the author's .

Use ColdFusion as a Scripting Language

No one ever said that ColdFusion is only for building database-driven applications. In fact, Cold Fusion's tag-based syntax and built-in functions make CFML a perfect language for small scripting jobs. These two examples demonstrate how to use ColdFusion as a scripting language.

To output the current date, merely stick the following CFML code in your page template where you want the date to appear:
 

Today's date is #DateFormat(Now(),'mmmm dd, yyyy')#

Likewise, you can use CFML to email the values submitted by an HTML form to a list of recipients. Put the following HTML code in the form's page:
 


Name:

Email:

 

Place this CFML code in a separate file called sendmail.cfm:
 

TO="recipient1@foo.com,recipient2@foo.com"
FROM="sender@foo.com"
CC="recipient3@foo.com"
SUBJECT="Sample form emailer">

The following information was submitted by the form:
=======================================
Name: #Name#
Email: #Email#

You might want to add some HTML to this sendmail.cfm page so that the user sees an acknowledgment or some other feedback that the message has been sent.

JavaScript vs. ColdFusion Validation

You can validate data entered by a user on the client side or the server side. Since ColdFusion is a server-side tool, it excels at server-side input validation. But there are times when client-side validation is a better way to go. Client-side validation doesn't force users to wait while the data is sent to the server, validated, and any error messages returned.

For client-side validation in ColdFusion, you have to use a scripting language such as JavaScript. Unfortunately, not all browsers support JavaScript, and many people with JavaScript-capable browsers deliberately disable that functionality for security or privacy reasons.

One solution is to use both client-side and server-side validation in your applications. It takes a bit of extra work to combine JavaScript and ColdFusion validation routines, but it can be worth it.

For example, suppose you have an HTML form that asks users to input their names and their email addresses. You want to require that the user enter something for both the Name and Email fields.

To ensure that forms submitted by users without JavaScript are properly validated with minimum delay, you might use both client- and server-side scripts:
 

 

Name:

Email:

 

It's a bit of extra coding, and it could mean validating the data twice--once by the JavaScript on the client side and again by ColdFusion on the server side. But it makes your pages more responsive for users with JavaScript browsers while still validating data for users with non-JavaScript browsers.

Identify Variable Scope

ColdFusion applications use a number of different variable types, or scopes. These scopes let ColdFusion identify the source of the variable.

ColdFusion variable scopes include:
 

  Variabletype: Scopesyntax:
 
Query
QueryName.variablename
  URLparameter URL.variablename
  Formfield Form.variablename
  CFSET Variable.variablename
  HTTPcookie Cookie.variablename
  CGIenvironment CGI.variablename
  Client Client.variablename
  Server Server.variablename
  Customtag (CFML) Attribute.variablename
 

Avoid Problems With Large Verity Collections

ColdFusion includes an implementation of 's popular Search '97 software, letting developers create and search collections of HTML files, most productivity-application documents (, PowerPoint, and so forth), , and even relational databases. Many Web builders, however, encounter problems trying to index large collections of documents with ColdFusion. Follow these three tips to help keep your Verity collections from causing problems:

  1. Keep your collections optimized. The ColdFusion administration interface has an option for optimizing your Verity collections. Use it often. If automation is your game, you can write and schedule a simple CFML template to do the optimizations for you.

     

  2. Consider numerous smaller collections. For example, if your site contains sections for marketing, sales, and products, consider creating a separate Verity collection for each section. Smaller collections are easier to manage, and you'll also be able to narrow searches to specific areas of your site. Your visitors will thank you.

     

  3. Increase memory. Nothing improves the performance of your Web applications more than additional server memory. With memory prices at an all-time low, it is a worthwhile investment.

If you still get errors indexing your files after optimizing your collections, splitting them into several sections, and adding memory to your server, consider purchasing a full-blown copy of Search '97 and creating your collections from that. ColdFusion can search external Verity collections created from the full product as well as from its bundled version of the search engine.

Alternate Table Row Colors

Tables with lots of rows can be hard to read, as the rows can seem to run together. One solution is to alternate the color of each row. On the client side, you might use to alternate cell background colors. On the server side, you can use Cold Fusion's Current Row variable and MOD function to determine which row of the query you are currently printing to your HTML page.
 

SELECT * FROM CustomerRecords

#CustomerName# #State#
#CustomerName# #State#


Did You Know?

  • ColdFusion along with Flash has very quickly become pride and a source of glory for Macromedia. ColdFusion gives a sense of programming intellegence behind its makers. Nevertheless, Macromedia has its roots in graphic design softwares.








Partners Links
- Steve is a ColdFusion MX Certified Developer who has been programming in ColdFusion since 1999. He is the author of a number of ColdFusion tools, including Custom Tags, CFCs and a few programs.