Chapter 4: Reading and debugging

Classes and objects

A class is a blueprint. Each object made from it with new gets its own data and shares the functions, called methods. Inside a method, the word this means the object it was called on.

Classes gather data and the rules for changing it in one place, and you will read plenty even if you never write one. When an agent's class grows long, ask what it holds and what changes it, because a class with many reasons to change is hard to review.

Say it to your agent

“This class has 14 methods and 9 fields. List which methods use which fields, and propose how to split it so each part has one reason to change. Do not refactor anything yet.”

The workshop

Name a word, or describe what you mean in everyday language.