Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of granularity in OOP [closed]

I was reading about the flyweight design pattern on this page.
I was not able to understand the meaning of the "granularity" in the context of programming languages or the design pattern.

Can anyone please explain, an example would be great.

like image 552
rgamber Avatar asked Oct 16 '12 17:10

rgamber


1 Answers

Granularity is a level of details. Granular objects are those, which are at low level detail in your program. Consider:

  • trees in game landscape
  • characters in document
  • seats in cinema
  • power points in cad application

Usually you have many granular objects in application. If you will create separate object for each tree/character/seat/power-point it could be very memory-consuming. Thats the problem which is solved by Flyweight pattern.

like image 198
Sergey Berezovskiy Avatar answered Oct 20 '22 17:10

Sergey Berezovskiy