Welcome!

You will be redirected in 30 seconds or close now.

ColdFusion Authors: Yakov Fain, Jeremy Geelan, Maureen O'Gara, Nancy Y. Nee, Tad Anderson

Related Topics: ColdFusion, Adobe Flex

ColdFusion: Article

Why Interfaces in ColdFusion Are Irrelevant

An overview

One of the many hotly contested items about ColdFusion in recent times that some developers have been clamoring for are the addition of interfaces to ColdFusion Components as part of the standard CFML language. At one time I was definitely in this camp myself - interfaces would indeed be a good way to make sure that components follow a given contract.

However, after much thought about the underlying implementation of them at a compile time and runtime level, I find them to be only a semantic difference to what you can already do with CFCs. While something akin to a <cfinterface> tag would make the implementation of a pseudo interface a slightly cleaner affair, the underlying implementation of interfaces in a dynamically typed language such as ColdFusion does not add much to the existing capabilities. In particular, the main purpose of an interface is to ensure that an object follows a contract, and this is technically infeasible in a dynamically typed language like ColdFusion.

A reasonable high-level comparison of dynamic languages to static languages could be summed up as a pair of safety scissors versus a razor blade. Static languages are the safety scissors - they help protect you from cutting yourself and will probably last longer, but it might take a long time to cut something. Dynamic languages are a razor blade - they are very sharp and nimble and cut through most things very quickly, but they are easy to cut yourself with if you're not careful and may have a shorter shelf-life depending on how they are used. This comparison is not valid for all languages, but works well for comparing a dynamically typed language such as ColdFusion and Python to a statically typed language like Java.

ColdFusion is dynamically typed because you don't have to specify the primitive data type of variables when they are created, as the CFML runtime examines a given variable and takes care of that for you. In general, this allows you, the developer, to concentrate on getting things done rather than managing each variable you create. Statically typed languages such as Java typically require the developer to declare the data type for all variables, and provide compile-time checking to make sure all variables and method signatures are typed correctly.

While it is generally more time-consuming to program in statically typed languages, it does provide more type safety and at a micro level has greater performance. One of the performance advantages would be that because the runtime can already be assured of which data type each variable contains, fewer CPU cycles are used introspecting data and turning it into code that a CPU can understand. There are plenty of other advantages and disadvantages between the two types of languages as well that are beyond the scope of this article.

When I find a need for an interface in ColdFusion, I essentially create my own pseudo interfaces that at least provide runtime checking in case an inheriting object's method is called. It's not necessarily the best solution, but it does at least offer some sort of contract that an inheriting object can be tied to, mostly for documentation purposes. I've seen several other people do it as well, but it looks something like this:

foobar/Foo.cfc

<cfcomponent hint="Interface for foo">
    <cffunction name="init" returntype="any">
       <return this />
    </cffunction>

    <cffunction name="implementThis" returntype="any">
       <cfthrow message="foobar.Foo: implementThis() must be implemented">
    </cffunction>
</cfcomponent>

foobar/Bar.cfc

<cfcomponent hint="Provides foobar functionality">
    <cffunction name="init" returntype="any">
       <return this />
    </cffunction>

    <cffunction name="implementThis" returntype="any">
       <cfreturn true />
    </cffunction>
</cfcomponent>

These are just some quick pseudo-code examples coded for brevity, but you get the idea.

As I started to question the usefulness of interfaces in ColdFusion in light of the way a lot of people are already doing them, I began to realize that the implementation of an interface tag or attribute to CFCs would not really offer any technical advantages at a runtime level, so largely their implementation is only a semantic difference.

In Java, one of the main advantages to using an interface is that it does compile-time checking to make sure that classes implementing interfaces follow the contract dictated by the interface as well as the full method signature of required arguments. As ColdFusion is a dynamically typed language, there really isn't a good way to do compile-time checking of interfaces. It is also impossible to do a full method signature of an object at compile time because of the nature of dynamically typing - the full signature of an object can change at runtime because of the flexibility inherent in dynamically typed languages.

One of the reasons I decided to write about this is that it's a subject that has been debated heavily in the community as a needed feature for the upcoming ColdFusion 8, currently code-named Scorpio. BlueDragon 7, currently in beta, does include an implementation of interfaces. I wrote a shortened preview version of this article on my blog, which drew some valuable dialog, in particular from Vince Bonfanti, the CEO of New Atlanta.

Vince discussed the nature in which interfaces are implemented in BlueDragon, which I think are technically sound and the way I would personally attempt to add interfaces into a dynamically typed language. However, any sort of interface implementation in a dynamic language such as ColdFusion are only semantics because you can't check the full method signature of an object until runtime, rather than at compile time as you can with static languages. While I do concur that the syntax is cleaner than in the example I provided earlier, I disagree in principle that it's a true interface. A counter-example I provided is how many developers using the open language Python have proposed interfaces over the years, but it's never been implemented for the reasons I've cited as well as due to disagreements in the syntax of its proposed implementation, among other reasons.

Summary
Due to the nature of dynamically typed languages, the implementation of interfaces in ColdFusion would not prevent someone from breaking the contract of an interface at runtime. Any implementation of interfaces in the CFML language would essentially only represent a difference in semantics to other ways already available to implement interface-like objects without providing the safety that interfaces should provide. There are bigger problems to solve and better features to implement in the next version of ColdFusion than interfaces.

More Stories By Brandon Harper

Brandon Harper has been programming in ColdFusion since 1998 and also actively writes applications in Python and Java. He is currently a Senior Software Developer at Acxiom where he works on an enterprise service platform which powers their risk mitigation products. Brandon was also a technical editor for Inside ColdFusion MX, and maintains a blog at devnulled.com.

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
CFDJ News Desk 01/03/07 06:04:14 PM EST

One of the many hotly contested items about ColdFusion in recent times that some developers have been clamoring for are the addition of interfaces to ColdFusion Components as part of the standard CFML language. At one time I was definitely in this camp myself - interfaces would indeed be a good way to make sure that components follow a given contract.

@ThingsExpo Stories
SYS-CON Events announced today that Dasher Technologies will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Dasher Technologies, Inc. ® is a premier IT solution provider that delivers expert technical resources along with trusted account executives to architect and deliver complete IT solutions and services to help our clients execute their goals, plans and objectives. Since 1999, we'v...
SYS-CON Events announced today that TidalScale, a leading provider of systems and services, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TidalScale has been involved in shaping the computing landscape. They've designed, developed and deployed some of the most important and successful systems and services in the history of the computing industry - internet, Ethernet, operating s...
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities – ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups. As a result, many firms employ new business models that place enormous impor...
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, will discuss how from store operations...
Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, will discuss some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he’ll go over some of the best practices for structured team migrat...
SYS-CON Events announced today that Taica will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Taica manufacturers Alpha-GEL brand silicone components and materials, which maintain outstanding performance over a wide temperature range -40C to +200C. For more information, visit http://www.taica.co.jp/english/.
SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, will discuss how they bu...
As hybrid cloud becomes the de-facto standard mode of operation for most enterprises, new challenges arise on how to efficiently and economically share data across environments. In his session at 21st Cloud Expo, Dr. Allon Cohen, VP of Product at Elastifile, will explore new techniques and best practices that help enterprise IT benefit from the advantages of hybrid cloud environments by enabling data availability for both legacy enterprise and cloud-native mission critical applications. By rev...
Join IBM November 1 at 21st Cloud Expo at the Santa Clara Convention Center in Santa Clara, CA, and learn how IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Cognitive analysis impacts today’s systems with unparalleled ability that were previously available only to manned, back-end operations. Thanks to cloud processing, IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Imagine a robot vacuum that becomes your personal assistant tha...
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
SYS-CON Events announced today that Datera will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Datera offers a radically new approach to data management, where innovative software makes data infrastructure invisible, elastic and able to perform at the highest level. It eliminates hardware lock-in and gives IT organizations the choice to source x86 server nodes, with business model option...
Infoblox delivers Actionable Network Intelligence to enterprise, government, and service provider customers around the world. They are the industry leader in DNS, DHCP, and IP address management, the category known as DDI. We empower thousands of organizations to control and secure their networks from the core-enabling them to increase efficiency and visibility, improve customer service, and meet compliance requirements.
Digital transformation is changing the face of business. The IDC predicts that enterprises will commit to a massive new scale of digital transformation, to stake out leadership positions in the "digital transformation economy." Accordingly, attendees at the upcoming Cloud Expo | @ThingsExpo at the Santa Clara Convention Center in Santa Clara, CA, Oct 31-Nov 2, will find fresh new content in a new track called Enterprise Cloud & Digital Transformation.
SYS-CON Events announced today that N3N will exhibit at SYS-CON's @ThingsExpo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. N3N’s solutions increase the effectiveness of operations and control centers, increase the value of IoT investments, and facilitate real-time operational decision making. N3N enables operations teams with a four dimensional digital “big board” that consolidates real-time live video feeds alongside IoT sensor data a...
SYS-CON Events announced today that NetApp has been named “Bronze Sponsor” of SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. NetApp is the data authority for hybrid cloud. NetApp provides a full range of hybrid cloud data services that simplify management of applications and data across cloud and on-premises environments to accelerate digital transformation. Together with their partners, NetApp emp...
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
SYS-CON Events announced today that Avere Systems, a leading provider of hybrid cloud enablement solutions, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Avere Systems was created by file systems experts determined to reinvent storage by changing the way enterprises thought about and bought storage resources. With decades of experience behind the company’s founders, Avere got its ...
SYS-CON Events announced today that Avere Systems, a leading provider of enterprise storage for the hybrid cloud, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Avere delivers a more modern architectural approach to storage that doesn't require the overprovisioning of storage capacity to achieve performance, overspending on expensive storage media for inactive data or the overbui...
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.