Skip to content

L10: Companion Objects and Object Declarations

In this lesson we will explore:

  • Deep Theory: object declarations (JVM-guaranteed thread-safe Singletons), companion object as the idiomatic replacement for static members, data object, and the Factory Pattern.
  • Under the Hood: How the JVM implements the Singleton pattern via a static INSTANCE field and lazy, thread-safe class initialization.
  • Incremental Lab (AI Chat CLI): Modeling chat connection events and global configuration state using Singletons and Companion Factories.