The value of graininess in OOP

I read about flyweight design pattern on this page .
I could not understand the meaning of "granularity" in the context of programming languages ​​or design patterns.

Can someone explain an example would be great.

+4
source share
1 answer

Granularity is the level of detail. Granular objects are those that are on low-level parts in your program. Consider:

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

Usually you have a lot of granular objects in the application. If you create a separate object for each tree / symbol / place / power point, this can be very time consuming. This is a problem that has been solved by the Flyweight method.

+12
source

Source: https://habr.com/ru/post/1440103/


All Articles