Home > Articles > Programming > Java

  • Print
  • + Share This
From the author of

Design Considerations

With the aforementioned comparison of BMP and CMP, here are the design issues you should consider before making your choice:

  • Nature of your data

  • Performance Constraints

  • Use of an object mapping tool (Toplink or CocoBase)

Nature of Your Data

In some instances, the nature of your data will make the determination for you.

These questions will usually cause you to use BMP:

  • Are you trying to provide a distributed front-end to a legacy system?

  • Are you using complicated data types (for example, CLOBs or BLOBs) that do not lend themselves nicely to simple object-mapping tools?

  • Are you providing an object-oriented representation of data that is by its nature relational (will your bean fields span multiple tables)?

  • Are you making heavy use of stored procedures in your system?

On the other hand, if your data is mostly standard data types, and you can effectively do a one-to-one mapping of beans to tables, CMP is what you want.

Performance Constraints

When considering performance, you must decide whether to make the trade-off between performance and convenience. Consider how your system is going to be used—if your EJBs are going to be accessed a dozen times a day and your domain does not require real-time performance, the time to build highly optimized code could be better spent somewhere else.

On the other hand, if you are writing beans that will run in the back end of a system such as Amazon, performance is of the utmost priority. In this case, you should consider your application server carefully, and you will want to squeeze every bit of performance out of your beans.

As I mentioned earlier, if performance is the most imporant consideration in your system, you will want to learn the EJB specification (especially with regard to lifecycles) carefully, and use BMP.

Use of an Object-Mapping Tool

If you are fortunate enough to have a powerful object-mapping tool at your disposal (such as Toplink or CocoBase), the decision is almost trivial. You can define your complicated bean field mappings in one of these tools, and then they (usually) generate highly optimized BMP beans for you.

This gives you the best of both worlds: convenience and performance, but at a high (monetary) price.

  • + Share This
  • 🔖 Save To Your Account