|By Samuel Neff||
|April 3, 2003 12:00 AM EST||
Components bring to ColdFusion MX developers much of the power and practices of object-oriented programming. The component implementation in ColdFusion MX introduces us to many of the principles of OOP, including encapsulation and inheritance. One aspect of these features is the ability to create new components that inherit or extend the functionality of other components.
In order to effectively extend functionality, developers often require the ability to override existing component functions as well as still call the original functions to incorporate their programming logic. Since ColdFusion MX doesn't currently provide this ability, we'll explore a technique to work around this limitation that enables us to call a parent component's overridden method.
With component-based development, related code can easily be grouped together in a consolidated entity, giving us the ability to encapsulate data and functionality. This consolidation can be further expanded with the ability to inherit functionality from a parent component, also called extension. When one component extends another, it can both reuse the functionality of the original component and add its own functionality.
Often, the new functionality added to a component will replace its original functionality. This is an advantage to developers who utilize the component in their code since the parent and child components will each have a similar call interface, or function names. By maintaining a consistent interface, developers can write code that can use either the parent or child component interchangeably without modifying the calling code.
For an example of this, see Listing 1, which sets up two components, GreetingBase.cfc and GreetingChild.cfc. GreetingChild extends the functionality of GreetingBase, and both provide a single function, sayGreeting, which returns a greeting to the caller. The caller can use either component and call the same function to retrieve the result appropriate for the component being used, a feature known in OOP as polymorphism.
Calling Overridden Parent Component Functions
We run into a limitation when we try to utilize the parent component functionality for a function that we've overridden, in this case sayGreeting. We want to add a function sayAllGreetings, which returns the results of both the parent and the child components' sayGreeting functions. While you can create an instance of the parent component and call the new instance's sayGreeting method, this would not return accurate results in cases where the call depends on data in the component instance. Unfortunately, there is no mechanism in ColdFusion MX to call an overridden parent method and have it run in the context of the calling component instance.
Many other OOP languages, such as Java and even ActionScript, allow calling a parent class's methods through the keyword Super. While ColdFusion MX does not provide this ability, there is an often-overlooked feature that we can use to achieve the desired effect.
ColdFusion stores function references and variables equally. A function can be called by referring to the function name followed by parentheses, as you are accustomed. Additionally, the function reference can also be utilized by simply referring to the function name. The most common utilization of this feature is to copy a function to another scope, and here we'll use this ability to make a parent component's functions available to its children.
Any code that exists within the cfcomponent tags and outside of any cffunction tags is executed when the component is instantiated. This code is most often used to set up or initialize the component and is called the Constructor in OOP terms.
<!--- constructor code goes here --->
In Listing 2 we added some code to our original components. GreetingBase.cfc now has two lines of code in the constructor.
<cfset super = structNew()>
<cfset super.sayGreeting = sayGreeting>
What we've done here is set up a structure called "super", which we'll use as a holder for our parent component methods. After creating the structure we use cfset to copy a reference to the function to our structure. It's important to note here that when this code is run, the component will exist only as the parent component, so any functionality that is overridden in the child component has not yet been incorporated.
With this structure created and our parent functions safely stored, we can utilize them in the child, GreetingChild.cfc, as follows:
<cfset var greetings="Parent says '" &
"', Child says '" &
sayGreeting() & "'">
In this code we put together a string in which we call our parent component's sayGreeting function, through our super structure, and also call the current sayGreeting function as we normally would.
Super Structure Limitations
Through a little creative utilization of obscure features, we've been able to implement a very important feature common to OOP. However, our implementation is not comprehensive and does have limitations.
This technique can only be used to implement one level of parent-component calls. Since each component in the inheritance chain does not have its own data location where we can store the parent component's methods, we can only store the methods from a single parent component.
Additionally, we must recognize that this is a workaround to provide for functionality missing from ColdFusion MX. Since this feature is standard for OOP and commonly requested from developers, Macromedia will probably implement this functionality natively in a future version of ColdFusion.
When adding support for parent-component calls, Macromedia is likely to use the keyword "super" in their own implementation since this is used in both Java and ActionScript. With this change, our code will stop working since "super" will become a keyword. While this may seem like a problem, it is actually an advantage.
Since we no longer need our workaround once parent component calls are implemented in ColdFusion, we want to ensure that we can easily remove this workaround when it becomes obsolete. To accomplish this, wrap all of the super workaround code, the parent-component constructor, inside consistent comments as shown in Listing 3.
With these comments, we can utilize the Regular Expression replace in either ColdFusion Studio or Dreamweaver to remove all of the super structures from our code. As long as the keyword super is used for this functionality natively, the rest of our code will continue to work.
Component-based development brings to ColdFusion MX many of the features of OOP. By using a structure and function references, we were able to bring a common feature of OOP to ColdFusion, albeit with limitations. In recognizing these limitations, we can write our code in a forward-thinking manner and facilitate future changes to the code when they come in conflict with possible new functionality.
Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more business becomes digital the more stakeholders are interested in this data including how it relates to business. Some of these people have never used a monitoring tool before. They have a question on their mind like “How is my application doing” but no id...
Aug. 27, 2016 03:15 AM EDT Reads: 1,755
Personalization has long been the holy grail of marketing. Simply stated, communicate the most relevant offer to the right person and you will increase sales. To achieve this, you must understand the individual. Consequently, digital marketers developed many ways to gather and leverage customer information to deliver targeted experiences. In his session at @ThingsExpo, Lou Casal, Founder and Principal Consultant at Practicala, discussed how the Internet of Things (IoT) has accelerated our abil...
Aug. 27, 2016 02:30 AM EDT Reads: 1,997
With so much going on in this space you could be forgiven for thinking you were always working with yesterday’s technologies. So much change, so quickly. What do you do if you have to build a solution from the ground up that is expected to live in the field for at least 5-10 years? This is the challenge we faced when we looked to refresh our existing 10-year-old custom hardware stack to measure the fullness of trash cans and compactors.
Aug. 27, 2016 01:45 AM EDT Reads: 1,725
The emerging Internet of Everything creates tremendous new opportunities for customer engagement and business model innovation. However, enterprises must overcome a number of critical challenges to bring these new solutions to market. In his session at @ThingsExpo, Michael Martin, CTO/CIO at nfrastructure, outlined these key challenges and recommended approaches for overcoming them to achieve speed and agility in the design, development and implementation of Internet of Everything solutions wi...
Aug. 27, 2016 01:15 AM EDT Reads: 2,001
Cloud computing is being adopted in one form or another by 94% of enterprises today. Tens of billions of new devices are being connected to The Internet of Things. And Big Data is driving this bus. An exponential increase is expected in the amount of information being processed, managed, analyzed, and acted upon by enterprise IT. This amazing is not part of some distant future - it is happening today. One report shows a 650% increase in enterprise data by 2020. Other estimates are even higher....
Aug. 27, 2016 12:45 AM EDT Reads: 2,929
SYS-CON Events announced today that 910Telecom will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Housed in the classic Denver Gas & Electric Building, 910 15th St., 910Telecom is a carrier-neutral telecom hotel located in the heart of Denver. Adjacent to CenturyLink, AT&T, and Denver Main, 910Telecom offers connectivity to all major carriers, Internet service providers, Internet backbones and ...
Aug. 26, 2016 10:00 PM EDT Reads: 1,854
SYS-CON Events announced today Telecom Reseller has been named “Media Sponsor” of SYS-CON's 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
Aug. 26, 2016 07:00 PM EDT Reads: 667
Smart Cities are here to stay, but for their promise to be delivered, the data they produce must not be put in new siloes. In his session at @ThingsExpo, Mathias Herberts, Co-founder and CTO of Cityzen Data, will deep dive into best practices that will ensure a successful smart city journey.
Aug. 26, 2016 04:45 PM EDT Reads: 1,539
DevOps at Cloud Expo, taking place Nov 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 19th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait for long dev...
Aug. 26, 2016 04:30 PM EDT Reads: 2,320
The 19th International Cloud Expo has announced that its Call for Papers is open. Cloud Expo, to be held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, brings together Cloud Computing, Big Data, Internet of Things, DevOps, Digital Transformation, Microservices and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding business opportuni...
Aug. 26, 2016 04:00 PM EDT Reads: 3,941
There is growing need for data-driven applications and the need for digital platforms to build these apps. In his session at 19th Cloud Expo, Muddu Sudhakar, VP and GM of Security & IoT at Splunk, will cover different PaaS solutions and Big Data platforms that are available to build applications. In addition, AI and machine learning are creating new requirements that developers need in the building of next-gen apps. The next-generation digital platforms have some of the past platform needs a...
Aug. 26, 2016 03:15 PM EDT Reads: 469
Pulzze Systems was happy to participate in such a premier event and thankful to be receiving the winning investment and global network support from G-Startup Worldwide. It is an exciting time for Pulzze to showcase the effectiveness of innovative technologies and enable them to make the world smarter and better. The reputable contest is held to identify promising startups around the globe that are assured to change the world through their innovative products and disruptive technologies. There w...
Aug. 26, 2016 11:30 AM EDT Reads: 608
Internet of @ThingsExpo, taking place November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 19th 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 devices - comp...
Aug. 26, 2016 10:15 AM EDT Reads: 3,592
Data is the fuel that drives the machine learning algorithmic engines and ultimately provides the business value. In his session at Cloud Expo, Ed Featherston, a director and senior enterprise architect at Collaborative Consulting, will discuss the key considerations around quality, volume, timeliness, and pedigree that must be dealt with in order to properly fuel that engine.
Aug. 26, 2016 09:45 AM EDT Reads: 1,864
19th Cloud Expo, taking place November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Meanwhile, 94% of enterpri...
Aug. 26, 2016 05:00 AM EDT Reads: 3,058
I wanted to gather all of my Internet of Things (IOT) blogs into a single blog (that I could later use with my University of San Francisco (USF) Big Data “MBA” course). However as I started to pull these blogs together, I realized that my IOT discussion lacked a vision; it lacked an end point towards which an organization could drive their IOT envisioning, proof of value, app dev, data engineering and data science efforts. And I think that the IOT end point is really quite simple…
Aug. 25, 2016 11:45 PM EDT Reads: 2,320
Identity is in everything and customers are looking to their providers to ensure the security of their identities, transactions and data. With the increased reliance on cloud-based services, service providers must build security and trust into their offerings, adding value to customers and improving the user experience. Making identity, security and privacy easy for customers provides a unique advantage over the competition.
Aug. 25, 2016 09:15 PM EDT Reads: 2,243
Is the ongoing quest for agility in the data center forcing you to evaluate how to be a part of infrastructure automation efforts? As organizations evolve toward bimodal IT operations, they are embracing new service delivery models and leveraging virtualization to increase infrastructure agility. Therefore, the network must evolve in parallel to become equally agile. Read this essential piece of Gartner research for recommendations on achieving greater agility.
Aug. 25, 2016 05:15 PM EDT Reads: 782
SYS-CON Events announced today that Venafi, the Immune System for the Internet™ and the leading provider of Next Generation Trust Protection, will exhibit at @DevOpsSummit at 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Venafi is the Immune System for the Internet™ that protects the foundation of all cybersecurity – cryptographic keys and digital certificates – so they can’t be misused by bad guys in attacks...
Aug. 25, 2016 01:00 PM EDT Reads: 2,638
For basic one-to-one voice or video calling solutions, WebRTC has proven to be a very powerful technology. Although WebRTC’s core functionality is to provide secure, real-time p2p media streaming, leveraging native platform features and server-side components brings up new communication capabilities for web and native mobile applications, allowing for advanced multi-user use cases such as video broadcasting, conferencing, and media recording.
Aug. 25, 2016 08:45 AM EDT Reads: 2,162