Hermes Wiki

Encapsulation Polymorphism

Hiding internal state behind a clear interface (encapsulation), and letting different types respond to the same call in their own way (polymorphism).

Why we need this / what value this brings

Encapsulation limits how many places can break when internal representation changes; polymorphism lets calling code stay simple even as the set of concrete types grows.

When to use this

Encapsulate any internal state that shouldn't be mutated directly by callers; reach for polymorphism whenever a caller currently branches on type to decide what to do.

How to use or implement this

Expose behavior through methods, not raw fields; replace if type == X: ... elif type == Y: ... blocks with each type implementing its own version of the method being branched on.

Research questions

  • Where does the codebase currently expose internal state that should be encapsulated behind a method instead?

Empty folder — drop notes, links, and findings here as you research.

Hermes Wiki