Mysql date function

Mysql date function

MYSQL Database About Us Links Downloads Contact Us Terms of use SiteMap
Mysql date function
Mysql date function

 

You are here: MYSQL Database >>Mysql date function

Mysql date function article lists.

Mysql date function

ColdFusion MX/J2EE hybrid applications: 10 best practices - cfmx/j2ee




Since the release of ColdFusion MX, the ColdFusion community has been rumbling about the possibilities made available by CFMX's powerful Java 2 Enterprise Edition (J2EE) underpinnings; using servlets, JavaServer Pages (JSP), JavaBeans, and Enterprise JavaBean (EJB) components are the most notable examples.

Out of this discussion has arisen the concept of ColdFusion/J2EE hybrid applications. As an ideal, CFMX/J2EE hybrids offer the rapid development and robust high-level services of CFMX, while integrating the deeper transactional and low-level programming power of Java.

With all of the possibilities for architecting and developing these hybrid applications, it seems to me that it's time for the ColdFusion development community to seriously discuss what some of the best practices might be when developing these hybrid applications. Surely there are infinite possibilities for integrating CFMX with J2EE, but which of these are viable and truly offer the best that both frameworks have to offer?

This is the question I have been asking myself again and again over the past few months while I collaborated on a book about this topic (Reality ColdFusion: J2EE Integration), developed applications (including the Lindex component using Apache Lucene for the Macromedia Developer's Resource Kit 3), and did a case study for Macromedia's DevNet site (www.macromedia.com/devnet/mx/cold fusion/j2ee/articles/hybrid.html) on hybrid applications. In short, I've been living a hybrid life. This article is not only to share what I've learned, but also to contribute to and further an ongoing discussion on best practices for CFMX/J2EE hybrid applications.

Note: in order to best focus on the subject at hand, I have foregone providing background on what the two environments, CFMX and J2EE, are. If you are looking for more background information on this subject, I suggest the following resources:

* Chapter 32 of the CFMX manual, "Developing ColdFusion MX Applications with CFML," online at http://livedocs.macromedia.com/cfmx docs/Developing_ColdFusion_MX_Ap plications_with_CFML/Java.jsp

* Ben Forta's online presentation at Macromedia DevNet (www.macrome dia.com/software/coldfusion/j2ee/spe cial/presentations/tech_intro/)

* Ben Forta's CFDJ column in Volume 5, issue 3, "ColdFusion & Java: More than just the sum of their parts"

* Reality ColdFusion: J2EE Integration, Forta, Falkman, et al (Macromedia Press)

ColdFusion MX and J2EE: A Good Match

What I've realized most in this process is that these two technologies really complement one another well. ColdFusion provides high-level services and an intuitive and rapid development framework, while J2EE provides low-level application programming interfaces (APIs) and powerful development objects. The most important thing to understand for anyone looking at developing hybrid applications is what each environment does well. Table 1 shows the key strengths and differences between both environments.

At the core, CFMX brings rapid development to J2EE, something it was clearly lacking before. Developers can learn and become proficient in using CFML in significantly less time than Java, which requires understanding object-oriented programming concepts, strict data types, and a vast library of programming constructs. At the same time, because of its object-oriented nature and vast library collection, Java offers a considerable amount of control for those who know how to use it.

In addition, the J2EE framework contains a number of programming constructs--such as EJBs and messaging services--that simply can't be emulated using ColdFusion alone. The best part of these differences is that there is no reason to choose one or the other anymore, just when to use which. This leads us to the heart of the matter: the best practices.

The 10 Best Practices Best Practice #1:

Use only what you need There's no reason to add complexity--ever. Introducing a second programming environment when you really need only one is nonsense. If you are building a CFMX application, don't use Java if you don't need to. The Java language is not as accessible as CFML--you'll add hours of learning, planning, and coding into your development process. Understand why you should use it first. With J2EE-only applications, you can likely gain a significant amount of time by using CFMX, even with the learning curve. However, if using CFMX means rewriting a significant amount of JSP/servlet code you may want to reconsider.

Best Practice #2: Use what you already have

Okay, this is another "no-duh" best practice, but I wouldn't feel right if I didn't mention it. If you have a CFML template that's handling a core, complex piece of business logic, don't recode it into an EJB or something else unless you have a compelling reason to do so. It needs to be distributed? Make it into a ColdFusion Component (CFC) and deploy it as a Web service. The same goes even more so for existing servlets and Java classes. It is relatively easy to integrate these items from within CFML. See the ColdFusion manual reference above for more information.

In fact, capitalizing on existing code is a central argument for hybrid applications--use the Java code you have already developed, but build around it in CFMX (and in half the time it would take to do so in Java). In addition, this point should include capitalizing on open-source (or closed-source, for that matter) code in both environments. The ColdFusion community has a number of good resources for CF tags and user-defined functions, and the Java community has a huge open-source and thirdparty product community--use this prebuilt, pretested code whenever possible.

Best Practice #3: Use CFMX for prototyping

ColdFusion, because of its rapid development capabilities, makes an ideal prototyping solution. You can easily plug in a Microsoft Access (or mySQL) database, some CFQUERY and CFOUTPUT tags, and bam! (sorry Emeril ... ) you're up and running with a pretty deep prototype. You can then capitalize on your prototype code by tightening it up, adding error handling, and maybe converting the back-end processing into EJBs or other Java components. This is especially useful if you use Best Practice #4 in your conversion process.

Best Practice #4: Use the CFC Facade pattern

If I had to pick a best best practice, this would be it. CFCs allow CFMX developers to create their own components containing functions. These functions are then called on from within any CFML template, and can even be exposed as Web services. CFCs are perfect for calling on Java classes of any kind. Let's say you have an EJB that calculates sales tax for in-state orders. The taxBean EJB has a method called getTaxOwed() that you pass the total sales amount to. In a hybrid application, you would create a CFC called eCommerce.cfc or something like that. Inside of this CFC, you would create a function called getTaxOwed() (sound familiar?). This is simply an abstraction of the Java code. Then you can use CFINVOKE or CFSCRIPT to call on the getTaxOwed() CF function.

This layer of abstraction makes irrelevant how the eCommerce.cfc works internally, thus allowing the getTaxOwed() CF function to call on an EJB or some other type of Java class, or even perform the logic itself. Using this pattern is great for prototyping--simply return dummy data in the prototype, and then when you plug it in for real, only the CFC needs to be changed. This is based on a well-established J2EE pattern called the Session Facade, whereby a session bean (EJB) is used to abstract logic of other EJB components. Figure 1 shows the CFC Facade pattern.

[FIGURE 1 OMITTED]

Best Practice #5: Use the M-V-C pattern, with CFMX handling the V and usually the C

M-V-C stands for Model-View-Controller. In this architecture, you have three primary sections of an application: the Model is the data model and includes data storage and logic processing; the View handles the user interface (UI); and the Controller handles the request and response (input/output) of the application. If you do not have existing servlets or JSP pages handling the UI and request/response processing (see Best Practice #2 above), let ColdFusion handle this.

Between the Application.cfm, OnRequestEnd.cfm, CFMX's built-in security, and other services, as well as other frameworks (such as Fusebox and variations thereof), CFMX can effectively control an application, and output the UI--whether the UI is HTML, Flash, or XML. It is in this capacity that CFMX really shines. Developing the View/Controller aspects of an application in CFML will take so much less time than developing servlets and JSP pages that your job might become a part-time position, or you at least will have time (finally!) to get up to date on the water-cooler gossip.

Best Practice #6: Use J2EE event listeners

Mysql date function Related Links
Mysql date insertMysql insert into
Mysql insert idVb script mysql
Csv import mysqlImport data to mysql
 
©2005 All Rights Reserved   MYSQL Database