GenServers for Code Organization

Learn about the strengths of the GenServer and whether it can be used for code organization.

Strengths of GenServer

We just saw an example that plays to all of the GenServer strengths. GenServer is a beautiful abstraction, and like anything good in the hands of an inexperienced developer, it’s prone to overuse. Let’s look at some of its properties. A GenServer does the following things:

  • It encapsulates a shared service.
  • It holds state.
  • It allows concurrent access to shared resources.
  • It handles supervision to take care of normal and abnormal startup and cleanup.

These are the problems a GenServer is built to solve. The previous ...