Welcome!

IBM Cloud Authors: Elizabeth White, Pat Romanski, Yeshim Deniz, Liz McMillan, Carmen Gonzalez

Related Topics: IBM Cloud

IBM Cloud: Article

Discovering and Documenting Business Application Patterns

Discovering and Documenting Business Application Patterns

Over the past two months, we've looked at the process of extracting a business application pattern from a series of business requirements. You've seen this pattern take shape, from its original form as a design meeting the specific needs of a particular business application (configurable product balance information) through an initial abstraction that was modified by other business requirements to reach its final form. In this article, the last of a three-part series, we'll look at applying the key pattern and cached balances pattern (with others) to the construction of applications, components, and Web services.

Reviewing Our Pattern
Last month's article concluded with a definition of our business application patterns: keys and cached balances. We tracked the maturation of these patterns through their initial concept as extracted from our product balances business requirement, to their modification due to additional requirements resulting from our application's need to flexibly manage financial account balances, to their representation both as abstract patterns and reusable partial implementations of each pattern (i.e., framelets). Our final patterns included an abstracted CachedBalanceSet class containing a set of balance values associated with abstracted access keys (the AccessKey class). These keys are controlled by another set of keys that specify their scope (the SpecificationKey class), and each of these key classes in turn contains a collection of key elements that implements an abstract Keyable interface that declares comparison methods such as equals (for AccessKeyable) and convert (for SpecificationKeyable). Figures 1 and 2 reflect these concepts in terms of UML.

Patterns Within the J2EE Architectural Context
Up to this point, we have not taken into account the specific demands and restrictions placed upon our pattern by the technical architecture within which it will be deployed. In other words, our pattern provides a set of high-level design guidelines that need to be adapted for specific use. Our choice of technical architecture is J2EE, and more specifically EJB. How does the EJB framework affect our low-level design choices when applying this pattern?

As we enter into the detailed design phase, let's review the characteristics of our CachedProductBalances class (and related classes and algorithms):

  • It represents a composite set of business information related to a specific business entity; namely the Product class.
  • Its methods are self-contained; i.e., their implementations do not depend upon making calls to other business entities.
  • Its methods will typically be called within the context of a broader business process (e.g., invoking updateBalance as part of incoming shipment processing) rather than as stand-alone business functionality.

    These characteristics need to be evaluated in the context of the EJB framework and the design options that framework presents. We should also rely on the experience of others in building robust J2EE applications - after all, that's what design patterns are all about. Let's take a look at some key design aspects and see what Core J2EE Patterns has to say about them.

    Entity Bean Design - the Composite Entity Pattern
    One of the early decisions we need to make when applying our pattern to EJB technology is which classes should be implemented as entity beans. The Composite Entity pattern states "entity beans are not intended to represent every persistent object in the object model. Entity beans are better suited for coarse-grained persistent business objects." Applying this principle to our high-level design for CachedBalanceSet, we see that most classes within this design are best left as simple Java classes; in other words, they are dependent objects. Should the CachedBalanceSet class itself be implemented as an entity bean? Given the previously listed characteristics (specifically that the CachedBalanceSet method implementations are self-contained), we can make a reasonable case for implementing CachedBalanceSet as an entity bean. However, we also need to consider what its relationship to the Product class should be and how its methods interact with broader business processes, as these points may very well cause us to revisit our initial decision.

    The Product class is a natural candidate for entity bean implementation. It represents a business entity with considerable information and functional behavior, and it presents us with a natural primary key - the product ID. If we implement the Product class as an entity bean, what effect does that have on our CachedBalanceSet class? Much depends upon the behavior we choose to expose on Product's interface. If we choose to treat the Product class primarily as a data holder, maintaining information such as product name, description, ID, and the like, without incorporating additional business process-related behavior (like product balance updating and retrieval), then we maintain a loose coupling between the Product class and the CachedBalanceSet class (see Figure 3). This lends credence to our tentative decision to implement the CachedBalanceSet class as an entity bean in its own right, but raises the question as to where to contain the business process- related behavior that manages product balances.

    Another aspect of the EJB architecture that we need to take into account is our ability to choose whether an entity bean is defined as local. Local entity beans reduce overhead associated with remote calls but at the expense of limiting access to the entity object to the local process. At this point in our design process we don't have clear guidance based on the Composite Entity pattern, but as we continue to expand our design toward components and Web services, we will see that local entity beans are the best choice for our design.

    If, on the other hand, we choose to embed product balance maintenance within the Product class, we see that we have introduced tight coupling between the Product class and the CachedBalanceSet class. Such tight coupling might cause us to reconsider our earlier decision to make the CachedBalanceSet class an entity bean, instead choosing to implement the CachedBalanceSet class as a dependent Java class within the Product class implementation (see Figure 4). However, this raises another question - how much overhead does introducing these dependent classes introduce to EJB activation and passivation? If our typical use of the Product class does not involve balance management, we might be better off separating the CachedBalanceSet class from the Product class as we originally proposed. If, on the other hand, most uses of the Product class involve balance management, then embedding the product balance management code as dependent objects within the Product class is probably the right decision. If we choose this option, we may be able to mitigate the EJB activation and passivation overhead through a bean-managed persistence (BMP) approach, deferring activation of the dependent CachedBalanceSet object within the Product EJB until it is needed. In fact, this is likely to be the choice we will make for CachedBalanceSets even if we choose to implement it as a separate entity bean, given that the internal intricacy of its contained objects, in this case as it is in general, involves a series of tradeoffs.

    Session Bean Design - the Session Facade Pattern
    Let's assume that we have chosen the decoupled approach as described above, resulting in two entity beans: Product and CachedBalanceSet. Where does the business logic responsible for maintaining product balances then reside?

    Again, Core J2EE Patterns gives us a strong hint. Reading from the Session Facade pattern, we see that a session bean "...manages the business objects and provides a uniform coarse-grained service access layer to clients." There are two important points being made here, one of which is directly applicable to our specific problem - session beans should be designed to manage underlying business objects. (We'll consider the second point when we discuss the relationship of Web services to components.) By introducing a WarehouseManagement session bean following the Session Facade pattern, we now have a natural place to locate our product balance maintenance implementation (along with many other business process-related algorithms that span products, warehouses, and other related business concepts such as lead and shipping time calculations (see Figure 5). By doing so, we have in fact created a coarse-grained component - one that presents a series of business services to clients without exposing those clients to the underlying complexity inherent in the implementation of those services. This approach also reinforces our earlier decision to separate product balance maintenance logic from the Product entity bean and maintain loose coupling between the Product and CachedBalanceSet classes.

    Now that we've introduced a session bean into our design, we need to consider whether this bean should be stateful or stateless. In general, Core J2EE Patterns recommends stateless session beans, as this allows the application server to more efficiently manage its memory pool by allocating beans out of a bean cache on a method-by-method basis. If, however, there is a need to maintain client session state outside of the client itself, then a stateful session bean approach may be warranted. In our case, we will assume that the stateless session bean approach is appropriate.

    Other design patterns may come into play as we drop down into the detailed design of our WarehouseManagement session bean. For example, we might choose to implement each of the methods our session bean exposes using the Strategy pattern, thus making our session bean highly configurable. Individual strategy implementations might in turn use the TemplateMethod pattern to provide a partially built algorithm that can be customized on a point-by-point basis. These are just a couple of examples of how design patterns can influence detailed design decisions.

    Bringing Web Services into the Picture
    Server-Side Considerations - the Transfer Object Pattern

    Now that we have our coarse-grained business services defined, we need to adapt them to the needs of potential clients. One type of client that is of considerable interest these days is remote invocation via a Web service. Web service- based invocation involves transmission of a client request to a remote service via an XML message whose format is specified by SOAP, typically transmitted over Internet protocols such as TCP/IP and HTTP. Introduction of this XML-based invocation into the picture adds some additional design restrictions above and beyond those created by the base J2EE architecture.

    Specifically, because our client communicates with our service via XML documents rather than remote objects (as would be the case in an n-tier J2EE implementation with JSPs and servlets invoking session bean methods through their remote interfaces via RMI), we need to ensure that the interface presented by our server component is easily consumable by the SOAP client and does not introduce a lot of overhead at the component (i.e., session bean) interface.

    The Transfer Object pattern provides us with an approach for consolidating the business information to be communicated between client and server. This pattern encourages the use of simple Java classes to encapsulate business data exposed on the public interface of a coarse-grained component. These simple data-oriented Java classes can then be easily processed by the serializer/deserializer logic provided by SOAP development and runtime frameworks such as those following the JAX-RPC specification.

    Client-Side Considerations - the Proxy and Business Delegate Patterns
    Remote Web services clients typically interact with a service via object-oriented proxies that are often generated by specialized Web services development tools from the WSDL document describing the service. These simple proxy classes provide individual methods for each of the operations described by the WSDL document. Each method directly invokes the underlying service (in our case the coarse-grained component implemented by our WarehouseManagement session bean) via the SOAP-based framework provided by the Web services runtime.

    In some cases, these directly generated client methods will be sufficient. There may be cases, however, in which it is desirable for the client to have an additional level of decoupling from the services it invokes. For example, we might choose to build up a cache of recently accessed product information to minimize remote activity and thus improve performance of our client, or we might want to build up a consolidated client view over multiple Web services. The Business Delegate pattern describes an approach that supports this level of isolation. Client activities occur solely through a client-side class, the Business Delegate, which in turn delegates any necessary remote invocations to the underlying business service (in this case our generated SOAP client). Because the Business Delegate class is interposed between the client code and the SOAP client, we have the freedom to introduce client-side caching for frequently accessed information, consolidated service groupings with embedded glue logic, or other useful features. The Business Delegate class can also serve as a stable interface point for the remainder of the client code, isolating any client-side changes that might result from changing server-side implementations to a single touch point.

    Summary
    Figure 6 shows our full set of patterns working in concert from client to server through a client request scenario. As you can see, by defining our pattern independently of the technical architecture, we were able to easily take advantage of a number of useful concepts:

  • Grouping related business function into loosely coupled entities with embedded dependent objects - the Composite Entity pattern
  • Providing cross-entity business process functionality via an encapsulating facade - the Session Facade pattern
  • Consolidating the business information transferred between client and server into simple data-oriented objects - the Transfer Object pattern
  • Accessing server-side functionality via client-side proxies - the Proxy pattern
  • Introducing additional client-side isolation classes to support service consolidation, client-side caching, and other advanced client-side capabilities - the Business Delegate pattern

    Underneath it all reside our original business patterns, doing the heavy lifting of managing our product balances.

    Resources

  • Alur, D.; Crupi, J.; and Malks, D. (2001). Core J2EE Patterns: Best Practices and Design Strategies. Prentice Hall.
  • Gamma, E.; Helm, R.; Johnson, R.; and Vlissides, J. (1994). Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley.
  • Carey, J. and Carlson, B. (2002). Framework Process Patterns: Lessons Learned Developing Application Frameworks. Addison-Wesley.
  • Carey, J.; Carlson, B.; Graser, T.; and Varlson, B. (2000). SanFrancisco Design Patterns: Blueprints for Business Software. Addison-Wesley.
  • More Stories By Brent Carlson

    Brent Carlson is vice president of technology and cofounder of LogicLibrary, a provider of software development asset (SDA) management tools. He is the coauthor of two books: San Francisco Design Patterns: Blueprints for Business Software (with James Carey and Tim Graser) and Framework Process Patterns: Lessons Learned Developing Application Frameworks (with James Carey). He also holds 16 software patents, with eight more currently under evaluation.

    Comments (0)

    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.


    @ThingsExpo Stories
    SYS-CON Events announced today that N3N will exhibit at SYS-CON's @ThingsExpo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. N3N’s solutions increase the effectiveness of operations and control centers, increase the value of IoT investments, and facilitate real-time operational decision making. N3N enables operations teams with a four dimensional digital “big board” that consolidates real-time live video feeds alongside IoT sensor data a...
    SYS-CON Events announced today that NetApp has been named “Bronze Sponsor” of SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. NetApp is the data authority for hybrid cloud. NetApp provides a full range of hybrid cloud data services that simplify management of applications and data across cloud and on-premises environments to accelerate digital transformation. Together with their partners, NetApp em...
    Real IoT production deployments running at scale are collecting sensor data from hundreds / thousands / millions of devices. The goal is to take business-critical actions on the real-time data and find insights from stored datasets. In his session at @ThingsExpo, John Walicki, Watson IoT Developer Advocate at IBM Cloud, will provide a fast-paced developer journey that follows the IoT sensor data from generation, to edge gateway, to edge analytics, to encryption, to the IBM Bluemix cloud, to Wa...
    There is huge complexity in implementing a successful digital business that requires efficient on-premise and cloud back-end infrastructure, IT and Internet of Things (IoT) data, analytics, Machine Learning, Artificial Intelligence (AI) and Digital Applications. In the data center alone, there are physical and virtual infrastructures, multiple operating systems, multiple applications and new and emerging business and technological paradigms such as cloud computing and XaaS. And then there are pe...
    SYS-CON Events announced today that B2Cloud will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. B2Cloud specializes in IoT devices for preventive and predictive maintenance in any kind of equipment retrieving data like Energy consumption, working time, temperature, humidity, pressure, etc.
    DevOps at Cloud Expo – being held October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA – announces that its Call for Papers is open. Born out of proven success in agile development, cloud computing, and process automation, DevOps is a macro trend you cannot afford to miss. From showcase success stories from early adopters and web-scale businesses, DevOps is expanding to organizations of all sizes, including the world's largest enterprises – and delivering real r...
    SYS-CON Events announced today that Suzuki Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Suzuki Inc. is a semiconductor-related business, including sales of consuming parts, parts repair, and maintenance for semiconductor manufacturing machines, etc. It is also a health care business providing experimental research for...
    SYS-CON Events announced today that Massive Networks, that helps your business operate seamlessly with fast, reliable, and secure internet and network solutions, has been named "Exhibitor" of SYS-CON's 21st International Cloud Expo ®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. As a premier telecommunications provider, Massive Networks is headquartered out of Louisville, Colorado. With years of experience under their belt, their team of...
    SYS-CON Events announced today that Fusic will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Fusic Co. provides mocks as virtual IoT devices. You can customize mocks, and get any amount of data at any time in your test. For more information, visit https://fusic.co.jp/english/.
    SYS-CON Events announced today that Ryobi Systems will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ryobi Systems Co., Ltd., as an information service company, specialized in business support for local governments and medical industry. We are challenging to achive the precision farming with AI. For more information, visit http:...
    SYS-CON Events announced today that Keisoku Research Consultant Co. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Keisoku Research Consultant, Co. offers research and consulting in a wide range of civil engineering-related fields from information construction to preservation of cultural properties. For more information, vi...
    SYS-CON Events announced today that Daiya Industry will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Daiya Industry specializes in orthotic support systems and assistive devices with pneumatic artificial muscles in order to contribute to an extended healthy life expectancy. For more information, please visit https://www.daiyak...
    SYS-CON Events announced today that Interface Corporation will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Interface Corporation is a company developing, manufacturing and marketing high quality and wide variety of industrial computers and interface modules such as PCIs and PCI express. For more information, visit http://www.i...
    SYS-CON Events announced today that Mobile Create USA will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Mobile Create USA Inc. is an MVNO-based business model that uses portable communication devices and cellular-based infrastructure in the development, sales, operation and mobile communications systems incorporating GPS capabi...
    In his session at @ThingsExpo, Greg Gorman is the Director, IoT Developer Ecosystem, Watson IoT, will provide a short tutorial on Node-RED, a Node.js-based programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using a wide range of nodes in the palette that can be deployed to its runtime in a single-click. There is a large library of contributed nodes that help so...
    Elon Musk is among the notable industry figures who worries about the power of AI to destroy rather than help society. Mark Zuckerberg, on the other hand, embraces all that is going on. AI is most powerful when deployed across the vast networks being built for Internets of Things in the manufacturing, transportation and logistics, retail, healthcare, government and other sectors. Is AI transforming IoT for the good or the bad? Do we need to worry about its potential destructive power? Or will we...
    SYS-CON Events announced today that mruby Forum will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. mruby is the lightweight implementation of the Ruby language. We introduce mruby and the mruby IoT framework that enhances development productivity. For more information, visit http://forum.mruby.org/.
    SYS-CON Events announced today that Nihon Micron will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Nihon Micron Co., Ltd. strives for technological innovation to establish high-density, high-precision processing technology for providing printed circuit board and metal mount RFID tags used for communication devices. For more inf...
    SYS-CON Events announced today that SIGMA Corporation will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. uLaser flow inspection device from the Japanese top share to Global Standard! Then, make the best use of data to flip to next page. For more information, visit http://www.sigma-k.co.jp/en/.
    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.