|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.
Cloud Expo 2014 TV commercials will feature @ThingsExpo, which was launched in June, 2014 at New York City's Javits Center as the largest 'Internet of Things' event in the world.
Nov. 22, 2014 09:00 AM EST Reads: 230
The major cloud platforms defy a simple, side-by-side analysis. Each of the major IaaS public-cloud platforms offers their own unique strengths and functionality. Options for on-site private cloud are diverse as well, and must be designed and deployed while taking existing legacy architecture and infrastructure into account. Then the reality is that most enterprises are embarking on a hybrid cloud strategy and programs. In this Power Panel at 15th Cloud Expo (http://www.CloudComputingExpo.com), moderated by Ashar Baig, Research Director, Cloud, at Gigaom Research, Nate Gordon, Director of T...
Nov. 22, 2014 07:00 AM EST Reads: 1,188
Explosive growth in connected devices. Enormous amounts of data for collection and analysis. Critical use of data for split-second decision making and actionable information. All three are factors in making the Internet of Things a reality. Yet, any one factor would have an IT organization pondering its infrastructure strategy. How should your organization enhance its IT framework to enable an Internet of Things implementation? In his session at Internet of @ThingsExpo, James Kirkland, Chief Architect for the Internet of Things and Intelligent Systems at Red Hat, described how to revolutioniz...
Nov. 21, 2014 09:15 PM EST Reads: 1,063
Technology is enabling a new approach to collecting and using data. This approach, commonly referred to as the "Internet of Things" (IoT), enables businesses to use real-time data from all sorts of things including machines, devices and sensors to make better decisions, improve customer service, and lower the risk in the creation of new revenue opportunities. In his General Session at Internet of @ThingsExpo, Dave Wagstaff, Vice President and Chief Architect at BSQUARE Corporation, discuss the real benefits to focus on, how to understand the requirements of a successful solution, the flow of ...
Nov. 21, 2014 08:00 PM EST Reads: 1,207
The security devil is always in the details of the attack: the ones you've endured, the ones you prepare yourself to fend off, and the ones that, you fear, will catch you completely unaware and defenseless. The Internet of Things (IoT) is nothing if not an endless proliferation of details. It's the vision of a world in which continuous Internet connectivity and addressability is embedded into a growing range of human artifacts, into the natural world, and even into our smartphones, appliances, and physical persons. In the IoT vision, every new "thing" - sensor, actuator, data source, data con...
Nov. 21, 2014 08:00 PM EST Reads: 1,093
"BSQUARE is in the business of selling software solutions for smart connected devices. It's obvious that IoT has moved from being a technology to being a fundamental part of business, and in the last 18 months people have said let's figure out how to do it and let's put some focus on it, " explained Dave Wagstaff, VP & Chief Architect, at BSQUARE Corporation, in this SYS-CON.tv interview at @ThingsExpo, held Nov 4-6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
Nov. 21, 2014 07:00 PM EST Reads: 1,081
ARMONK, N.Y., Nov. 20, 2014 /PRNewswire/ -- IBM (NYSE: IBM) today announced that it is bringing a greater level of control, security and flexibility to cloud-based application development and delivery with a single-tenant version of Bluemix, IBM's platform-as-a-service. The new platform enables developers to build ap...
Nov. 20, 2014 11:00 PM EST Reads: 1,237
Focused on this fast-growing market’s needs, Vitesse Semiconductor Corporation (Nasdaq: VTSS), a leading provider of IC solutions to advance "Ethernet Everywhere" in Carrier, Enterprise and Internet of Things (IoT) networks, introduced its IStaX™ software (VSC6815SDK), a robust protocol stack to simplify deployment and management of Industrial-IoT network applications such as Industrial Ethernet switching, surveillance, video distribution, LCD signage, intelligent sensors, and metering equipment. Leveraging technologies proven in the Carrier and Enterprise markets, IStaX is designed to work ac...
Nov. 20, 2014 09:15 PM EST Reads: 1,265
"There is a natural synchronization between the business models, the IoT is there to support ,” explained Brendan O'Brien, Co-founder and Chief Architect of Aria Systems, in this SYS-CON.tv interview at the 15th International Cloud Expo®, held Nov 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
Nov. 20, 2014 07:30 PM EST Reads: 1,437
C-Labs LLC, a leading provider of remote and mobile access for the Internet of Things (IoT), announced the appointment of John Traynor to the position of chief operating officer. Previously a strategic advisor to the firm, Mr. Traynor will now oversee sales, marketing, finance, and operations. Mr. Traynor is based out of the C-Labs office in Redmond, Washington. He reports to Chris Muench, Chief Executive Officer. Mr. Traynor brings valuable business leadership and technology industry expertise to C-Labs. With over 30 years' experience in the high-tech sector, John Traynor has held numerous...
Nov. 20, 2014 06:00 PM EST Reads: 1,219
Bit6 today issued a challenge to the technology community implementing Web Real Time Communication (WebRTC). To leap beyond WebRTC’s significant limitations and fully leverage its underlying value to accelerate innovation, application developers need to consider the entire communications ecosystem.
Nov. 20, 2014 04:45 PM EST Reads: 974
The 3rd International @ThingsExpo, co-located with the 16th International Cloud Expo - to be held June 9-11, 2015, at the Javits Center in New York City, NY - announces that it is now accepting Keynote Proposals. 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 - computers, smartphones, tablets, and sensors - connected to the Internet by 2020. This number will continue to grow at a rapid pace for the next several decades.
Nov. 20, 2014 01:00 PM EST Reads: 1,466
The Internet of Things is not new. Historically, smart businesses have used its basic concept of leveraging data to drive better decision making and have capitalized on those insights to realize additional revenue opportunities. So, what has changed to make the Internet of Things one of the hottest topics in tech? In his session at @ThingsExpo, Chris Gray, Director, Embedded and Internet of Things, discussed the underlying factors that are driving the economics of intelligent systems. Discover how hardware commoditization, the ubiquitous nature of connectivity, and the emergence of Big Data a...
Nov. 20, 2014 12:30 PM EST Reads: 1,702
Almost everyone sees the potential of Internet of Things but how can businesses truly unlock that potential. The key will be in the ability to discover business insight in the midst of an ocean of Big Data generated from billions of embedded devices via Systems of Discover. Businesses will also need to ensure that they can sustain that insight by leveraging the cloud for global reach, scale and elasticity.
Nov. 18, 2014 09:00 PM EST Reads: 1,958
SYS-CON Events announced today that Windstream, a leading provider of advanced network and cloud communications, has been named “Silver Sponsor” of SYS-CON's 16th International Cloud Expo®, which will take place on June 9–11, 2015, at the Javits Center in New York, NY. Windstream (Nasdaq: WIN), a FORTUNE 500 and S&P 500 company, is a leading provider of advanced network communications, including cloud computing and managed services, to businesses nationwide. The company also offers broadband, phone and digital TV services to consumers primarily in rural areas.
Nov. 18, 2014 08:15 PM EST Reads: 1,506
SYS-CON Events announced today that IDenticard will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. IDenticard™ is the security division of Brady Corp (NYSE: BRC), a $1.5 billion manufacturer of identification products. We have small-company values with the strength and stability of a major corporation. IDenticard offers local sales, support and service to our customers across the United States and Canada. Our partner network encompasses some 300 of the world's leading systems integrators and security s...
Nov. 18, 2014 08:15 PM EST Reads: 1,438
IoT is still a vague buzzword for many people. In his session at @ThingsExpo, Mike Kavis, Vice President & Principal Cloud Architect at Cloud Technology Partners, discussed the business value of IoT that goes far beyond the general public's perception that IoT is all about wearables and home consumer services. He also discussed how IoT is perceived by investors and how venture capitalist access this space. Other topics discussed were barriers to success, what is new, what is old, and what the future may hold. Mike Kavis is Vice President & Principal Cloud Architect at Cloud Technology Pa...
Nov. 18, 2014 01:30 PM EST Reads: 1,966
Cloud Expo 2014 TV commercials will feature @ThingsExpo, which was launched in June, 2014 at New York City's Javits Center as the largest 'Internet of Things' event in the world. The next @ThingsExpo will take place November 4-6, 2014, at the Santa Clara Convention Center, in Santa Clara, California. Since its launch in 2008, Cloud Expo TV commercials have been aired and CNBC, Fox News Network, and Bloomberg TV. Please enjoy our 2014 commercial.
Nov. 13, 2014 05:00 AM EST Reads: 3,511
From a software development perspective IoT is about programming "things," about connecting them with each other or integrating them with existing applications. In his session at @ThingsExpo, Yakov Fain, co-founder of Farata Systems and SuranceBay, will show you how small IoT-enabled devices from multiple manufacturers can be integrated into the workflow of an enterprise application. This is a practical demo of building a framework and components in HTML/Java/Mobile technologies to serve as a platform that can integrate new devices as they become available on the market.
Nov. 10, 2014 12:30 PM EST Reads: 2,620
The 3rd International Internet of @ThingsExpo, co-located with the 16th International Cloud Expo - to be held June 9-11, 2015, at the Javits Center in New York City, NY - announces that its Call for Papers is now open. The Internet of Things (IoT) is the biggest idea since the creation of the Worldwide Web more than 20 years ago.
Nov. 10, 2014 12:00 PM EST Reads: 5,918