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

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.
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.


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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

825 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