This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
You are designing an Enterprise Application to provide a way for customers to buy products from many companies through one standard site. The application servers you have use the EJB specification 1.1. You have a customer bean and are not sure whether to use CMP or BMP. When should you use CMP?
AWhen performance is essential and you are storing standard data types.
BWhen performance is not essential and you are storing standard data types.
CWhen performance is essential and you are storing complex data types.
DWhen performance is not essential and you are storing complex data types.
I think performance wise, BMP is better than CMP. Also, in CMP if we use PrimaryKey class we can use object mapping to create complex object types. So it could be B and D.
The application server is using the EJB 1.1 specs. So the context this question positions itself in is clear enough. Containers are yet not sophisticated to the point of doing this mapping efficiently. Additional note: While, the promise of encapsulating the queries in an access object is that you have 'loose coupled' your entity beans with the data query, insert and update chores. Complex data types needs additional scrutiny of this access object code. Ofcourse the tradeoff here is that you make your queries more efficient manually, plus the management overhead of life cycles of objects in your application.
single best thing an ideal programmer can wish for is the ability to communicate his code.