Last week, I was chatting with two friends who talking about Coldfusion, OOP and PHP. One of them told me that she is so far to use OOP language since she become Coldfusion programmer. At that time, I was speechless why she can tell us like that. Maybe, it's lack of her Coldfusion programming language or because of the coding standard of our current company. In our current, we used Coldfusion language and Oracle but almost the Coldfusion coding are outdated of course. That's why I cannot write any updated coding even I wish because of the existing coding standard. Well, I was supposed to explain we can write OOP style in Coldfusion but she would think I'm teaching her. That's why I just closed my mouth.

Another my friend PHP developer told me that he is getting sick of why Coldfusion is based on tag-based programming. At that time, I need to explain him about we can develop non tag-based coding in Coldfusion and can write OO style as well. That's why I've wrote simple OO and non tag-based coding for these two programmers.

age.cfc

view plain print about
1component {
2    public string function getAge(required Struct sPerson){
3        currentAge = DateDiff("yyyy", sPerson.dateofbirth, now());
4        return currentAge;
5    }
6}

person.cfc

view plain print about
1component {
2    public struct function getPerson(required String pName, required String pDOB){
3        sPerson = structNew();
4        sPerson.fullname = arguments.pName;
5        sPerson.dateofbirth = arguments.pDOB;
6        return sPerson;
7    }
8}

index.cfm

view plain print about
1<cfscript>
2     sP = New Person();
3     sA = New Age();
4     getMe = sP.getPerson("PPShein", "7-April-1983");
5     myAge = sA.getAge(getMe);
6     WriteOutput(getMe.Fullname);
7     WriteOutput(" is ");
8     WriteOutput(myAge & " years old.");
9
</cfscript>

And the outcome will be as follow

view plain print about
1PPShein is 28 years old.

So who can complaint Coldfusion is tag-based programming and cannot be OO style coding.