• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Coarse-grained Objects

 
Srinivas Modekurti
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone explain what is the meaning of fine-grained and coarse-grained objects in the context of EJBs.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A coarse grained object does not usually provide a detailed view of the underlying and related objects. Coarse grained objects are often called components because their goal is to provide a higher level view of the underlying world which is composed of, as you might guess, fine grained objects, that is, objects that provide a very detailed low-level view of the system.

To sum up, at the bottom we have fine-grained objects and on top of them coarse grained objects that provide clients with a bulkier access to the system.

In the context of EJBs, The naive approach would be for the client to work directly with entity beans and implement some process in the client code. This is not really efficient in terms of the number of network roundtrips that are needed to carry out the operations. A better approach would be to have entity beans that can be fine- or coarse-grained depending on what properties they expose, and have session beans access those entity beans to implement some kind of process that the client can remotely run. This way, the client only needs to call one method on the remote session bean and the latter takes cares of accessing the underlying entity beans. In this case, the session bean provides a coarse-grained view over the fine-grained underlying entity beans.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic