The Benefits of CMP Over BMP

In Java programming, each business object, such as a customer, order or product, is represented by what is known as an entity bean. Programmers can choose from two types of entity beans, known as container-managed persistence beans and bean-managed persistence beans. Persistence refers to the property of a programming language that allows objects and variables to continue to exist from one execution of a program to the next. Not only do CMP entity beans require less programming, but also they are more flexible, more portable and easier to maintain than BMP entity beans.

  1. Programming

    • One of the main advantages of CMP entity beans over BMP entity beans is that they require less effort on the part of the programmer. With CMP entity beans, programmers write only the business logic and leave the other aspects to what is known as an Enterprise JavaBean container. The EJB container provides a run-time environment for CMP entity beans and acts as an intermediary between the business logic, written by the programmer, and the rest of the application. As a result, applications written using CMP entity beans require fewer lines of program code than those written using BMP entity beans, in which programmers are responsible for writing persistence, relationship management and business logic.

    Maintenance

    • An entity bean that manages its own persistence -- in other words, a BMP entity bean -- must, by definition, contain data access methods. This means that not only is there more program code to write in the first place but also more code to maintain. CMP beans, on the other hand, separate business logic from physical database details -- data access and management code is generated automatically during deployment -- and are easier to maintain as a result.

    Flexibility & Portability

    • With BMP entity beans, programmers must write query statements to manage persistence based on the target data source. Programmers must write Structured Query Language statements for a specific relational database -- which may not be portable to other relational databases -- and Object Query Language statements for an object database. With CMP entity beans, on the other hand, applications can be deployed with a flexible deployment tool, which generates the appropriate query statements regardless of the type of data source.

    Performance

    • Programmers don’t need to learn application programming interfaces specific to any data source to generate optimized, high-performance code using CMP entity beans. Code optimization simply involves translating EJB Query Language statements into native API calls and can be performed automatically by a deployment tool, with high levels of success. With BMP entity beans, programmers need to write optimized code for a particular database themselves, so need expert knowledge of that database.

Related Searches:

References

Comments

Related Ads

Featured