Sobes.tech
Junior — Middle

How to determine the optimal level of general abstraction in software development?

sobes.tech AI

Answer from AI

Optimal abstraction level is such that the code is sufficiently generalized to be reusable and flexible, but not so complex as to become incomprehensible.

To determine it, you should:

  • Evaluate how often the logic you want to abstract is repeated. If there are few repetitions, abstraction may be excessive.
  • Ensure that abstraction does not complicate code understanding. If you have to write many additional classes or interfaces, consider simplifying.
  • Use the KISS principle (Keep It Simple, Stupid) — do not overcomplicate without necessity.
  • Check how easily the code can be changed and extended with the current abstraction.

In practice, it’s a balance between reusability, maintainability, and simplicity. For example, in iOS, protocols are often used for abstraction, but creating too many protocols without real benefit is not recommended.

How to determine the optimal level of general… - sobes.tech