Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

coarse-grained vs. fine-grained

 
jane wen
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello guys,

I am preparing SCWCD. at the design pattern part, I am confused by two terms: coarse-grained and fine-grained. anybody like explain that to me? thanks
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fine grained methods tend to be small and modular. They are written to acheive one thing, such as getName(). Fine grained methods don't make up entire business use cases, they are simply fragments. Coarse grained methods, on the other hand, tend to accomplish several steps. An example might be saveNewBigOrder(BusinessObject obj), where this method validates data, saves data to the data store, and sends an email to the president of the company. The coarse grained method might call several fine grain methods on itself or other objects in order to acheive this functionality.

Often, course and fine grained methods are discussed when the architecture is distributed, such as a physical web tier contacting a physical remote business tier that contacts a remote data tier. The main point of making your methods coarse grained is to reduce network traffic. For instance, you would not want your web tier making the following fine grained remote calls, businessObj.validateData(), businessObj.saveData(), businessObj.emailPresident(). Using these fine grained methods means three trips across the network from the web tier to the business tier. Instead, the web tier might call one coarse grained method businessObj.saveNewBigOrder() that accomplishes all three previously mentioned tasks in one remote method call.

I hope that helps.
 
jane wen
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
like a crystal. thank you very much, Anthony
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic