Explain the term "Granularity"

Posted on 2002-04-08
Last Modified: 2012-08-14
Greetings all,

Could someone explain what the term "granualrity" means please when used in the context of object-oriented systems.

Question by:ruff_ryder
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

jamoville earned 50 total points
ID: 6925595
Application Granularity:
One of the goals of object-oriented design is finer granularity. The purpose is to achieve a greater level of abstraction than possible with data/procedures-oriented design.
An application constructed with more finely granular objects (i.e. a lower number of functions per object) is likely to be more easily maintained because objects should be smaller and less complex.

More finely granular objects should also be more reusable. ... Therefore, each object's behavior should be more easily understood and analyzed.

                                 Total Number of Objects
      Application Granularity =  -------------------------
                                   Total Function Points"


Author Comment

ID: 6927307
Hi jamoville,

I rejected you answer just so that we can have more discussion on this. I really want to make sure I'm understanding properly.

From what you've posted, This is what I understand:

Object Granularity describes how rich/complex a class' interface is. That is, if a class has a large interface, then it has a fine granularity, if small interface it has a large Granularity (i.e closer to 1.0).

I'm working this based on the formula you gave with one object and small and large interface accordingly.

Expert Comment

ID: 6927365
Simply put, the granularity is a measure of the amount of functionality (in terms of actual code and contained objects) a object contains. The finer the granularity, the simpler the object is. In OOD this is the goal - have a lot of simple objects in stead of a huge complex one. The reasons are easy to understand - maintainabilty, upgradeablity, re-use and so on.

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Author Comment

ID: 6927383
Ok, I get you there. But doesn't having alot of objects in a system make it complex as well in terms of design?

Expert Comment

ID: 6927587
Initially, it might seem so. However, any given system has got X amount that it must do, and that must be explained/detailed in your design (if the design is to implemented thoroughly). So, whether you have a 10 page description of one class, or 10 single page descriptions of smaller classes with an extra page describing interactions, you end up with roughly the same amount of "work" to do in the design.

Of course there is overhead introduced by using smaller, simpler classes. But this initial outlay is more than compensated for in later stages of the development life-cycle when the inevitable addendums and alterations to the design happens. Also, for the programmers that has to implement the design, it is much easier to digest and implement/debug/test smaller pieces, if each piece is an independent entity.

Of course, there is a limit to everything. Breaking a class apart just for the sake of making it smaller isn't the idea.  
LVL 16

Expert Comment

ID: 6928429
Referring to your post of 04/08/2002 10:03PM, note that the granularity of the object with the smaller interface would be finer.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question