This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mark Cade's Study Guide p. 28 Q13: Benefit using DAO with BMP Entity Bean

 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

please view the following question from Mark Cade's SCEA Study Guide p.28:


Which is a benefit of using DAOs with BMP-based entity beans?
  • A. Less code than a CMP entity bean
  • B. Faster data access than CMP
  • C. Reduced coupling with entity bean
  • D. Easier to code than CMP entity bean



  • What's the correct answer? Please with a small explanation .

    Regards,
    Darya
     
    Peer Reynders
    Bartender
    Posts: 2968
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Which part of the explanation given on page 31 do you have trouble with? It states that A and D are not true and that B isn't guarantueed. And a DAO can encapsulate/hide the implemented entity model through the additional layer of indirection - reducing the coupling of the clients (that use the DAO) to the implemented entity model.
    [ November 07, 2005: Message edited by: Peer Reynders ]
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Peer,

    I was pointing to Answer B having in mind that only with the begin of EJB 2.0 CMP we had a better performance.

    On the other hand I thought that DAO is simply an interface for persistence operations (create, read, update, delete and finder methods) which must not be related to an entity bean at all but connects directly to a JDBC data source .

    Hence Answer C (as you say) does not make sense to me .

    Regards,
    Darya
     
    Tom Adams
    Ranch Hand
    Posts: 56
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I would think that "C. Reduced coupling with entity bean" means that the DAO code is not tied to an entity bean implementation. So, you could redeploy the DAO code behind a session bean or on the web tier. With CMP you are highly coupled with the entity bean model.
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Tom,

    the question says that the DAO is used with an BMP entity bean and NOT with a seesion bean. Honestly I find this question very confusing .

    Regards,
    Darya
     
    Peer Reynders
    Bartender
    Posts: 2968
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Tom Adams:
    I would think that "C. Reduced coupling with entity bean" means that the DAO code is not tied to an entity bean implementation.


    The DAO code is tied to the entity model implementation - its the client(s) of the DAO that are decoupled from the entity model implementation because they use the DAO's interface, not the interfaces of the entity beans.

    Originally posted by Darya Akbari:
    I was pointing to Answer B having in mind that only with the begin of EJB 2.0 CMP we had a better performance.


    The outcome of the performance comparison between BMP and CMP (in any version) is highly dependent on the BMP developer's knowledge of the underlying datamodel and the skill of that developer in exploiting the strengths of the RDMBS engine through properly formulated SQL. It would be quite easy to implement a poorly performing BMP entity bean - hence there is no guarantee.

    Originally posted by Darya Akbari:
    On the other hand I thought that DAO is simply an interface for persistence operations (create, read, update, delete and finder methods) which must not be related to an entity bean at all but connects directly to a JDBC data source.


    Here you have fallen victim to the simplified examples that are usually used to explain the DAO pattern. A DAO can be the persistence interface for a composite object of arbitrary complexity (to any form of persistence (e.g. flat-file)) - not just an object that is equivalent to a single row in the table. There is no inherent relationship between the DAO pattern and the use of JDBC.

    In J2EE, DAO seems to refer to a number of Data Source Architectural Patterns. Even Martin Fowler stated that it is not clear whether a J2EE DAO is in fact a Row Data Gateway or a Table Data Gateway (P of EAA p.146). In some cases I have seen the term DAO used when the code is actually implementing a Data Mapper.

    Originally posted by Darya Akbari:
    the question says that the DAO is used with an BMP entity bean and NOT with a seesion bean.


    I think Tom was merely the referring to the additional layer of indirection that session beans typically add in the case of the session facade - in some ways, in the context of this question, the DAO takes the place of the session bean. With the session facade the client accesses the session bean instead of the entity bean - in this question the client accessed the DAO instead of the entity bean.
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Peer,

    Thanks for detailed response and referring to p.146 of Martin Fowler's Patterns of Enterprise Application Architecture. I can't find on p.146 that Martin Fowler is referring to J2EE's DAO.

    When I view the J2EE DAO definition I don't see the coupling of the DAO class to an entity bean class :roll: . Can you give me a link where I can find more about your explanations?

    Beside of that, are we supposed to know about the J2EE Patterns? As far as I know we must know all GOF Patterns for the SCEA 310-051 exam but not the J2EE Patterns.

    Regards,
    Darya
     
    Peer Reynders
    Bartender
    Posts: 2968
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Darya Akbari:
    I can't find on p.146 that Martin Fowler is referring to J2EE's DAO.


    Look under "Further Reading" in the "Table Data Gateway" section.
    He refers to Core J2EE Patterns: Best Practices and Design Strategies (Alur et al.) and also notes that Microsoft has a totally different meaning for Data Access Object and DAO. He also mentions the Gateway base pattern.

    Originally posted by Darya Akbari:
    Can you give me a link where I can find more about your explanations?


    I'm just going by the fact that the statements in connection with the DAO are very general.

    Originally posted by Darya Akbari:
    Beside of that, are we supposed to know about the J2EE Patterns? As far as I know we must know all GOF Patterns for the SCEA 310-051 exam but not the J2EE Patterns.


    I admit that I was also under the impression that only GOF patterns are covered, see the J2EE Patterns thread. Mark Cade is the one that brings it up in his book - you are the one with the gift of getting him to come out of the woodwork - you did it twice, maybe you should try again.
    Most likely it is assumed that the DAO pattern is an integral part of J2EE orthodoxy and nobody thinks its even worth mentioning separately anymore.
     
    Mark Cade
    author
    Ranch Hand
    Posts: 36
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    In the multiple choice section of the test, we only deal with GoF patterns. This example question is used to stimulate thought and conversation as it has here. You may use the J2EE Design Patterns in your submission.
     
    Peer Reynders
    Bartender
    Posts: 2968
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    ROTFL
    That is the third time a Darya Akbari thread did it!
    Thank You for your response Mark.

    PS: Still no decision whether the next SCEA (whenever it may materialize) will be J2EE 1.4 or Java EE 5?
    (Not really expecting to see an answer ... any time soon.)
    [ November 10, 2005: Message edited by: Peer Reynders ]
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    ROTFL too

    Regards,
    Darya
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic