CodeIEB
Theory Notes/🗄️ Topic 4: Data & Information Management, Solution Development/11.4.6
11.4.6Grade 11

Transferring Data Between Objects

How the frontend/UI and the backend/object classes actually communicate — and how methods communicate with each other.

Communication happens in both directions between the user interface (frontend) and the object classes (backend), and between methods (including private helper methods) within a class.

Parameters can send data to methods as:

  • A single primitive variable (e.g. an int or double value).
  • An entire object (passing a whole Learner object into a method, for example).

Typed methods/functions can return data as:

  • A single primitive variable.
  • An entire object.
  • A String with multiple fields packed together, separated by a delimiter character like # — often used to return several related values from one method when a full object return isn't practical.

Example

// Returning multiple values packed into one delimited String public String getSummary() { return name + "#" + grade + "#" + average; }

Null parameters — passing null as an argument (for an object-type parameter) can be used as a mechanism for abstraction, e.g. signalling 'no value provided' so a single, more generic method can handle multiple slightly different situations, reducing the need for several near-duplicate methods (a code efficiency technique).

Scope
The region of code within which a variable, field, or parameter is accessible/visible. A parameter's scope is normally limited to the method it belongs to; a field's scope is normally the whole class.
Lifetime
How long a variable/field/parameter exists in memory — a local variable/parameter typically exists only while its method is executing, while an object's fields exist for as long as the object itself exists.

💡 Exam Tip

Scope and lifetime are frequently tested together — a variable declared inside a method (local scope) cannot be accessed outside that method, and it stops existing (its lifetime ends) as soon as the method finishes executing.