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
When growing capacity and power in the data center, the architectural trade-offs between server scale-up vs. scale-out continue to be debated. Both approaches are valid: scale-out adds multiple, smaller servers running in a distributed computing model, while scale-up adds fewer, more powerful servers that are capable of running larger workloads. It’s worth noting that there are additional, unique advantages that scale-up architectures offer. One big advantage is large memory and compute capacity...
Artificial intelligence, machine learning, neural networks. We’re in the midst of a wave of excitement around AI such as hasn’t been seen for a few decades. But those previous periods of inflated expectations led to troughs of disappointment. Will this time be different? Most likely. Applications of AI such as predictive analytics are already decreasing costs and improving reliability of industrial machinery. Furthermore, the funding and research going into AI now comes from a wide range of com...
No hype cycles or predictions of zillions of things here. IoT is big. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, Associate Partner at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He discussed the evaluation of communication standards and IoT messaging protocols, data analytics considerations, edge-to-cloud tec...
"When we talk about cloud without compromise what we're talking about is that when people think about 'I need the flexibility of the cloud' - it's the ability to create applications and run them in a cloud environment that's far more flexible,” explained Matthew Finnie, CTO of Interoute, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
We build IoT infrastructure products - when you have to integrate different devices, different systems and cloud you have to build an application to do that but we eliminate the need to build an application. Our products can integrate any device, any system, any cloud regardless of protocol," explained Peter Jung, Chief Product Officer at Pulzze Systems, in this SYS-CON.tv interview at @ThingsExpo, held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA
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.
In his session at @ThingsExpo, Eric Lachapelle, CEO of the Professional Evaluation and Certification Board (PECB), provided an overview of various initiatives to certify the security of connected devices and future trends in ensuring public trust of IoT. Eric Lachapelle is the Chief Executive Officer of the Professional Evaluation and Certification Board (PECB), an international certification body. His role is to help companies and individuals to achieve professional, accredited and worldwide re...
The Internet giants are fully embracing AI. All the services they offer to their customers are aimed at drawing a map of the world with the data they get. The AIs from these companies are used to build disruptive approaches that cannot be used by established enterprises, which are threatened by these disruptions. However, most leaders underestimate the effect this will have on their businesses. In his session at 21st Cloud Expo, Rene Buest, Director Market Research & Technology Evangelism at Ara...
SYS-CON Events announced today that Enzu will exhibit at SYS-CON's 21st Int\ernational Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Enzu’s mission is to be the leading provider of enterprise cloud solutions worldwide. Enzu enables online businesses to use its IT infrastructure to their competitive advantage. By offering a suite of proven hosting and management services, Enzu wants companies to focus on the core of their ...
Internet of @ThingsExpo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devic...
Amazon started as an online bookseller 20 years ago. Since then, it has evolved into a technology juggernaut that has disrupted multiple markets and industries and touches many aspects of our lives. It is a relentless technology and business model innovator driving disruption throughout numerous ecosystems. Amazon’s AWS revenues alone are approaching $16B a year making it one of the largest IT companies in the world. With dominant offerings in Cloud, IoT, eCommerce, Big Data, AI, Digital Assista...
SYS-CON Events announced today that Cloud Academy named "Bronze Sponsor" of 21st International Cloud Expo which will take place October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara, CA. Cloud Academy is the industry’s most innovative, vendor-neutral cloud technology training platform. Cloud Academy provides continuous learning solutions for individuals and enterprise teams for Amazon Web Services, Microsoft Azure, Google Cloud Platform, and the most popular cloud com...
SYS-CON Events announced today that MobiDev, a client-oriented software development company, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MobiDev is a software company that develops and delivers turn-key mobile apps, websites, web services, and complex software systems for startups and enterprises. Since 2009 it has grown from a small group of passionate engineers and business...
SYS-CON Events announced today that GrapeUp, the leading provider of rapid product development at the speed of business, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Grape Up is a software company, specialized in cloud native application development and professional services related to Cloud Foundry PaaS. With five expert teams that operate in various sectors of the market acr...
SYS-CON Events announced today that Ayehu will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara California. Ayehu provides IT Process Automation & Orchestration solutions for IT and Security professionals to identify and resolve critical incidents and enable rapid containment, eradication, and recovery from cyber security breaches. Ayehu provides customers greater control over IT infras...
With the introduction of IoT and Smart Living in every aspect of our lives, one question has become relevant: What are the security implications? To answer this, first we have to look and explore the security models of the technologies that IoT is founded upon. In his session at @ThingsExpo, Nevi Kaja, a Research Engineer at Ford Motor Company, discussed some of the security challenges of the IoT infrastructure and related how these aspects impact Smart Living. The material was delivered interac...
In his session at Cloud Expo, Alan Winters, an entertainment executive/TV producer turned serial entrepreneur, presented a success story of an entrepreneur who has both suffered through and benefited from offshore development across multiple businesses: The smart choice, or how to select the right offshore development partner Warning signs, or how to minimize chances of making the wrong choice Collaboration, or how to establish the most effective work processes Budget control, or how to ma...
IoT solutions exploit operational data generated by Internet-connected smart “things” for the purpose of gaining operational insight and producing “better outcomes” (for example, create new business models, eliminate unscheduled maintenance, etc.). The explosive proliferation of IoT solutions will result in an exponential growth in the volume of IoT data, precipitating significant Information Governance issues: who owns the IoT data, what are the rights/duties of IoT solutions adopters towards t...
SYS-CON Events announced today that CA Technologies has been named "Platinum Sponsor" of SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CA Technologies helps customers succeed in a future where every business - from apparel to energy - is being rewritten by software. From planning to development to management to security, CA creates software that fuels transformation for companies in the applic...
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.