M6 · State, Resources, Two-Axis GrowthSession 12StructuralStill needed as-isOutline

Intent. Share common intrinsic state across many objects to cut memory.

In Kotlin. No language feature replaces it. You build the pool yourself.

Share intrinsic state so a large number of objects costs less memory. One of the few patterns no Kotlin feature replaces, and one you will not need until you suddenly do – icon and glyph caches, tile rendering, very large lists. The discipline it teaches is separating state that is intrinsic to the object from state that belongs to the context using it.

Structure

classDiagram
    class FlyweightFactory {
        -pool
        +get(key) Flyweight
    }
    class Flyweight {
        -intrinsicState
        +operation(extrinsicState)
    }
    class Client {
        -extrinsicState
    }
    FlyweightFactory o--> Flyweight : shared pool
    Client --> FlyweightFactory
    Client ..> Flyweight : passes extrinsic state in