2.1 Communicating entities

When a given entity receives a message from another entity, it triggers a specific behavior. The receiving entity of the message is called the receiver and the sending entity, the sender. In Cuis-Smalltalk terminology, an entity is called an instance of a class, a class instance, or simply an instance. A class is a kind of model for an entity.

The behavior is defined internally in the receiver and it can be triggered from any instance. Behaviors are invoked only by messages sent between entities. An entity may send a message to itself. A behavior is defined in a class and is called a method.

This results in a huge cloud of entities communicating with each other through message sending. New entities are instantiated when needed then automatically garbage collected when no longer required. On a fresh Cuis-Smalltalk environment, the count of class instances is more than 150000.

ProtoObject allSubclasses sum: [ :class | class allInstances size] 
⇒ 152058

Example 2.1: Calculating the number of entities

The count of classes, the models for the entities – instances of the class Class – is less than 700.

Smalltalk allClasses size
⇒ 671

Example 2.2: Calculating the number of classes

 note Because you are not using the base image but one used to teach classes, you will likely see a much larger number.

To be honest, in our previous chapter we skipped this important detail on Smalltalk design. We wrote about message sending without explaining much, we wanted you to discover this design informally. The scripts you read and wrote were all about entities communicating with each other through messages.