Just What IS a CLASS Anyway?
OO Terms in a Coldfusion Context
Which phrasing is correct:
1."Hey boss, take a look at this object I just wrote!"
2."Hey boss, take a look at this class I just wrote!"
The answer is number 2. After reading the following definition, hopefully the phrasing in choice 1 will sound strange to you.
The term "CLASS" tends to be misused, or even UNDERused in OO conversations with regard to Coldfusion, and is very often omitted in favor of the term Object. There is, however, an important distinction between the two. Let's illustrate this by asking a simple question that I KNOW you know the answer to.
Can you open a CFC in notepad?
The answer is "Heck yeah!" Why is this true? Because in reality, a CFC is JUST A TEXT FILE with a '.cfc' extension. It's the content, however, of this text file that makes it special, because what it contains are the blueprints that Coldfusion uses to create living breathing objects. So, when you tell Coldfusion something like
<cfset objUser = createobject("component","model.user")>
you're actually saying "CF, go find the user.cfc file, open it up, read the contents, and give me back a living breathing OBJECT that is built according to the blueprints."
In a very small nutshell then,
A Class is the definition used to create an object.
The class tells Coldfusion what methods to create, what variables are available, what items are returned...gosh, it tells CF every little detail about how the finished product (object) should behave and respond!
Class = CFC = Blueprint
For contextual illustration, a Java ".class" file is also just a text file containing the blueprints that Java needs in order to construct a Java object. A CFC is a Coldfusion class containing the blueprints CF needs in order to construct a Coldfusion object.
The plan...the blueprint...the CFC... it's what the rest of the OO world refers to as a CLASS, and so should you!
(this definition along with all the others I've collected over the past year can be found in my personal OO Lexicon)
1."Hey boss, take a look at this object I just wrote!"
2."Hey boss, take a look at this class I just wrote!"
The answer is number 2. After reading the following definition, hopefully the phrasing in choice 1 will sound strange to you.
The term "CLASS" tends to be misused, or even UNDERused in OO conversations with regard to Coldfusion, and is very often omitted in favor of the term Object. There is, however, an important distinction between the two. Let's illustrate this by asking a simple question that I KNOW you know the answer to.
Can you open a CFC in notepad?
The answer is "Heck yeah!" Why is this true? Because in reality, a CFC is JUST A TEXT FILE with a '.cfc' extension. It's the content, however, of this text file that makes it special, because what it contains are the blueprints that Coldfusion uses to create living breathing objects. So, when you tell Coldfusion something like
<cfset objUser = createobject("component","model.user")>
you're actually saying "CF, go find the user.cfc file, open it up, read the contents, and give me back a living breathing OBJECT that is built according to the blueprints."
In a very small nutshell then,
A Class is the definition used to create an object.
The class tells Coldfusion what methods to create, what variables are available, what items are returned...gosh, it tells CF every little detail about how the finished product (object) should behave and respond!
Class = CFC = Blueprint
For contextual illustration, a Java ".class" file is also just a text file containing the blueprints that Java needs in order to construct a Java object. A CFC is a Coldfusion class containing the blueprints CF needs in order to construct a Coldfusion object.
The plan...the blueprint...the CFC... it's what the rest of the OO world refers to as a CLASS, and so should you!
(this definition along with all the others I've collected over the past year can be found in my personal OO Lexicon)
Subscription Options
You are not logged in, so your subscription status for this entry is unknown. You can login or register here.
Re: Just What IS a CLASS Anyway?
I honestly can't say that's what the rest of the OO world refers to them, simply because many people brought into development using newer languages or simply higher level than C++ / Java really do refer to them as objects intantiated or not. In all truth, what are you going to use the source code for other than compiling or reading / writing? Nitpicking that seems kind of pointless when most people would refer to it as "the object / class source code".
I think the term really came to usage with Java by the meaning your referring to because when I learned C++, the only difference between a struct and class was that a class defaulted its members to provide (though this is a standard that changed over my learning to suggest that structs should only contain data members).
Your points are very valid, but I guess I can understand some of the gray area people have due to their programming history hehe.
Mike.
I think the term really came to usage with Java by the meaning your referring to because when I learned C++, the only difference between a struct and class was that a class defaulted its members to provide (though this is a standard that changed over my learning to suggest that structs should only contain data members).
Your points are very valid, but I guess I can understand some of the gray area people have due to their programming history hehe.
Mike.
Posted by Mike Kelp on September 14, 2007 at 8:27 PM

