Chapter 3. Why Use An Architectural Framework?

Table of Contents

Summary
Component Based Applications - Changing the Software Process
Industry Focus on Shared Standards
Why is there a Need for Frameworks?
What is a Framework?
What Advantages do Frameworks Offer?
Conclusion
Contributors

Note

If you find this EDG documentation helpful please consider DONATING! to keep the doc alive and current.

 Maintainer:David Lloyd

Summary

Every Enterprise Java project has the same basic plumbing. By embracing this premise, you can cut project costs and improve software quality in one swoop. Choosing an extensible, vendor-neutral solution with source code makes it all the more valuable. We'll look at some basic components to demonstrate how you can add new services easily while maintaining a consistent API to developers using the framework, thus ensuring future extensibility. We'll also look at the issues pertaining to cross-application server portability. Most enterprise applications have a great deal in common - no matter what the application does or who uses it. Every enterprise application requires services such as security, logging, configuration support, monitoring, automated testing, persistence, data exchange, and so on. In most projects, each service is either developed "from scratch", or pieced together from different vendor offerings. This process is repeated project after project, with little or no reuse even though the same basic needs do not change between applications. Clearly if these common services could be pulled into a core framework that could be tested once and reused across many projects, it would be a huge benefit to nearly every enterprise web application project not to mention cutting project costs and improve software quality in one swoop. Every developer can recite the advantages of component-based development, where components are created and tested once and then reused again and again. Yet how often do we really reuse components? How many of us have written a custom logging class? How many of us have written our own database connection pool? How about a persistence framework? I certainly have, more times than I would like to admit. I found that a large portion of my time was being spent writing "plumbing" code for common services, rather than on business logic specific to the application. I knew that there must be a better way. A few years ago, I set out to find a framework that could provide the common application functionality that I did not want to "reinvent". I had already decided on the Java 2 Enterprise Environment as the basis for our projects, based on its clear and powerful API, cross-platform functionality, maturity, and support. I looked for a framework that encouraged tight adherence to the Servlet and JSP specs, as I did not want to get "locked in" to a proprietary framework or methodology. It is easier to to find programmers experienced with the Java specifications than it is to find programmers experienced with framework X or vendor package Y. I also decided that for a framework to really suit my needs, I had to have access to the source code. As I would find out, this was not the only benefit to using open source software. This article was written as a result of my search for a J2EE-based open source web application framework. We will define frameworks, discuss the advantages of using frameworks, and compare some of the leading frameworks on a number of criteria. We will introduce the Expresso Framework and Struts, two excellent open source frameworks that compliment each other and have had a huge impact on my projects.

Component Based Applications - Changing the Software Process

Developer thinking has shifted from object-oriented design to component-based design. While similar, there are significant differences between the approaches. Frameworks and class libraries are now playing critical roles in enterprise web application development. Object-oriented design and development is a popular style of programming used for designing, developing and maintaining large and sophisticated applications. This style can be used to write a stand-alone application, a "fat" front-end for a client-server application, or a component for any tier in a multi-tier application. Object-oriented programming is an advanced technique supported to some degree by almost all modern programming languages. Component-based design brings a further level of refinement to software architecture. Components are being written based on a particular component standard (COM, JavaBeans, Enterprise JavaBeans, Corba, etc.) and should be pluggable by a tool and/or application. Components not only encapsulate a unit of functionality (like a class in object-oriented design), but also have a discoverable structure/interface used by other components, applications, development tools or component servers. Typically, each component is a reusable, independent unit that can be combined with other components. In many cases, writing an application entails assembling a wall from several ready-made component bricks and a few of your own. This assembly process can be sophisticated if you need to tune the level of thickness of each layer, optimize performance and resources, and integrate components from different vendors.

What are the benefits of using Components?

  • Reduced risk and reduced cost of project deployment.O pen and shared standards assures tried and true quality.

  • Enhanced opportunities with a repository of reusable application code.

  • A faster and improved rapid development.

  • Increased utilization of staff across different project solutions.

  • Reduced risk and a reduced cost by dramatically lowering the amount of low-level coding.

In short, frameworks reduce development time while improving delivered software quality - which means that developers can spend more time concentrating on the business-specific problems at hand rather than on the code behind the scenes. A good framework also enhances the maintainability of software through API consistency, comprehensive documentation, and thorough testing. "By 2003 at least 70% of the total number of new applications will be built primarily from "building blocks" such as software components and application frameworks, increasing both product speed to market and enterprises ability to cope with change," according to Michael Blechar of the Gartner Group, further "The future of application development lies with an open architecture that facilitates component choice, assembly and integration." "IS organizations must have a strategy for the inevitable shift to component-based development. Components in the form of design patterns, application frameworks and business and technical components can significantly increase quality and productivity in development through reuse . Reuse, in turn, can significantly lower cost and shorten time-to-market." Today's market requires organizations world-wide to deploy and use applications ever more rapidly and efficiently. This situation leads to the growing need for reusable software components. So, analysts estimate that by 2003, the software component market will grow from $7 billion to $30 to $60 billion .

Industry Focus on Shared Standards

The Web has become hugely successful because its protocols are independent of hardware, databases, and operating systems. All of the major operating systems implement the TCP/IP protocols, and HTTP is universally supported by web servers and web clients. Java brings a similar ubiquity to server-side application services. While not a universal standard such as HTTP, Java virtual machines (JVM's) are available for nearly every major server operating system. The Java specifications process is based on community collaboration, and the Java APIs are well documented and widely supported. Similarly, XML is quickly becoming the standard for exchanging data, replacing less flexible fixed-layout specifications. Java and XML are a natural fit, and the support for XML in the Java language overshadows the XML capabilities of any other programming language. Increasingly, when developers think of XML, they think of Java for programming and tool support.

Open source software is benefiting from these standards, while also improving the usability and adoption of these standards through tool support and reference implementations. Open source can evolve at an incredible pace when compared to conventional proprietary software development. The quality of the code improves through the efforts of a larger pool of motivated talent. Enhancements can be more rapidly incorporated and redeployed to the user community, resulting in a significant reduction in overhead costs. The feedback loop between user requirements and programmer delivery is then dramatically shortened for faster response to today's accelerated time-to-market imperative. Collaborative Communities illuminates an emerging pattern of business development fundamental to success in the networked economy.

Why is there a Need for Frameworks?

The web application developer needs a library of component-level objects to choose from to construct web applications quickly and consistently. Every developer knows the process - over the course of building a few applications you start to collect reusable code - sometimes just a routine or utility, sometimes an entire subsystem (such as security or database access). As you begin to re-use these pieces, you get more efficient at doing the next project, and the next. Usually, the more specific your toolbox is to the types of applications you're building, the easier the task. If you build a toolbox for graphic manipulations, it's not too handy when your next project is an accounts receivable system. You may have written several components and integrated them together. If they are being deployed as mission critical applications they require several other key features such as consistent error handling, database connections, synchronous or asynchronous process execution, and so on. Another consideration is that application components should be transparent in switching from one service flavor to another. An example is switching the connection type from ODBC to JDBC or error logs from a text file to a pager. Here is where the application framework comes into play. A framework can make it very easy to quickly build sophisticated web applications. Rather than simple Java Servlets that merely enable access to a database, a framework allows you to build entire systems, with secure, high-performance database access via an object-to -relational mapping (no need to embed SQL in your code), background job queuing and handling with dynamic invocation of custom server-side objects, and sophisticated event notifications and logging to facilitate management of your completed application. Developers can focus on creating the business logic and layout of the UI. All the tedious infrastructure work is already there to build upon, so that creating applications is easy and fast. Frameworks can capture best practices and make them pervasive. A framework provides a platform that enables rapid server application development. Its open standards, open architecture approach allows enterprise solutions to stay in step with the latest Java development. New technologies can be easily incorporated into the framework's structure and work seamlessly with existing components and services. As Java technology evolves, any solution that incorporates the framework can evolve with it. A framework provides the tools for creating complex Java server applications while mitigating the risks resulting from the velocity of business and the heterogeneity of system architectures. It achieves this goal by providing a a combination of software subsystems, referred to as services. Services can be reused and shared to assemble applications tailored to specific business applications. It is this capability to reuse services, as well as the flexibility to add new services, that addresses the quick time-to-market concerns. In addition, the modular assembly of an application from services provides a means for integrating heterogeneous systems.

What is a Framework?

So what is a framework? A framework is a set of prefabricated software building blocks that programmers can use, extend, or customize to suit their application. It is an object oriented reuse mechanism that allows the developer to decompose an application into a set of interacting objects. It describes the interfaces implemented by the framework components, the flow of control between these components, and the contracts between the components and the system. In this way the framework is a reusable design. The standard interfaces and interactions make it possible to mix and match existing components and create a wide variety of systems from a core set of components. With frameworks, developers don't have to start from scratch each time they build an application. The inherent flexibility enables the rapid creation and deployment of software solutions in a constantly evolving business environment. Having said that there are numerous types of frameworks - some of which that work together. For example Tapestry might be called a presentation framework and is not an alternative to Struts; Struts can use Tapestry for the presentation. Struts is a reference implementation of the MVCII specification. Jetspeed and Liferay (integrated with Struts) are portal frameworks. Expresso (integrated with Struts) is an architectural framework. A Java web development framework is a collection of tools and API's that enhance Sun's standard Java APIs by providing:

  • Structure to web development

  • Generic services that are needed on most projects (logging, persistence, etc...)

  • Tools and methods that simplify and accelerate web development.

While differences exist between class libraries and frameworks, some libraries exhibit framework-like behavior, and some frameworks are used like class libraries. This can be view as a continuum, with traditional class libraries at one end and frameworks at the other.

Table 3.1. 

Library:
  • Set of classes instantiated by client

  • Client calls functions

  • No predefined flow of control

  • No predefined interaction

  • No default behaviour

Framework:
  • Provides for customization by subclassing

  • Calls client functions

  • Controls flow of execution

  • Defines object interaction

  • Provides default behaviour

Application frameworks in particular encompass a horizontal slice of functionality that call be applied across client domains. The Expresso Framework for example supports the standard functionality required by most web based, multi-tiered applications. Key features of application development frameworks are that they provide several vital services across the application and application components.

  1. First, the framework must have these services implemented.

  2. Second, the application itself must be written in a particular manner that follows the framework methodology in order to take the advantage of these prewritten services.

  3. Third, components should have the possibility to plug these services in as needed. This may sound like a lot of effort to jump to a new application framework, but the application framework wizards can make this easier - asking what kind and how many application services you need for example. Wizards can also generate a good skeleton of your application code - for example as WebAppWriter does for Expresso.

The result of using a framework for n-tier applications is that the quality of the application increases dramatically while decreasing total cost of ownership and speeding time-to-market. Frameworks capture the programming expertise and best practices necessary to solve a particular class of problems without to reinvent the wheel.

What Advantages do Frameworks Offer?

TODO

Conclusion

Contributors

The following persons have contributed their time to this chapter:

Note

Was this EDG documentation helpful? Do you wish to express your appreciation for the time expended over years developing the EDG doc? We now accept and appreciate monetary donations. Your support will keep the EDG doc alive and current. Please click the Donate button and enter ANY amount you think the EDG doc is worth. In appreciation of a $35+ donation, we'll give you a subscription service by emailing you notifications of doc updates; and donations $75+ will also receive an Expresso T-shirt. All online donation forms are SSL secured and payment can be made via Credit Card or your Paypal account. Thank you in advance.

Copyright © 2001-2004 Jcorporate Ltd. All rights reserved.