liveBook · Manning

Instance variable

An instance variable is data associated with a particular object, rather than shared across all instances of its class or type.

How 4 Manning books explain it

The Well-Grounded Rubyist, Fourth Edition

An instance variable is a Ruby variable identified by a single-at-sign prefix and associated with an individual object.

How it is used
Stores per-object state so methods can retrieve or change values after initialization.
How deep it goes
Explains assignment, persistence across calls, ownership through `self`, and inspection with `instance_variables`.
Examples
Uses tickets with distinct venues and dates, a person's persistent name, and runtime inspection of accessor-backed variables.
What you can do after
Build it from scratch: initialize per-object state, expose or change it through methods, and identify its owner using `self`.

Read how The Well-Grounded Rubyist, Fourth Edition explains instance variable →

Software Design for Python Programmers

An instance variable is state associated with an individual object instance.

How it is used
Models per-object state, class-owned relationships, and runtime state transitions in object-oriented application design.
How deep it goes
Explains state, visibility, dependencies, multiplicity, and defensive copying, but stops short of general language-level attribute mechanics.
Examples
Uses catalogue objects, Employee birthdates, and an automatic ticket machine to demonstrate storage, protection, and state changes.
What you can do after
Evaluate/understand how object state, ownership, visibility, and mutation paths affect class design.

Read how Software Design for Python Programmers explains instance variable →

100 Java Mistakes and How to Avoid Them

How it is used
Prevents object-specific data from becoming accidentally shared through a static field.
How deep it goes
Explains per-object versus per-class storage, failure under concurrency, mutable static state, and applicable inspections.
Examples
Uses a Person name field and a concurrent TreeWalker queue to expose shared-state leakage.
What you can do after
Diagnose accidental static state by comparing field ownership with object usage and applying IDE or SonarLint inspections.

Read how 100 Java Mistakes and How to Avoid Them explains instance variable →

Secrets of the JavaScript Ninja, Second Edition

A property that belongs directly to a particular object instance rather than being inherited from its prototype.

How it is used
Contrasts properties stored on an object instance with properties supplied through its prototype.
How deep it goes
Explains constructor assignment, property precedence, and per-instance copies, then flags repeated methods as a concern for many objects.
Examples
Uses Ninja instances with `swung` and competing `swingSword` methods to demonstrate property ownership and precedence.
What you can do after
Understand which same-named property is found and why constructor-created methods are duplicated across instances.

Read how Secrets of the JavaScript Ninja, Second Edition explains instance variable →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.