💭 What is it?

Learners believe that when calling a function, the names of the arguments must exactly match the names of the parameters defined in the function header.

For example, they assume that if a function has a parameter named username, the variable used as an argument must also be called username:

void setup() {
	String username = "Alex";
	greet(username);
}

void greet(String username) {
	println("Hello, " + username);
}

If the argument has a different name, learners may believe the function call will result in an error:

void setup() {
	String user = "Alex";
	greet(user); // Learner expects an error
}

void greet(String username) {
	println("Hello, " + username);
}

🛠️ Why is it incorrect?

In Processing, when calling a function, only the type and position of each argument must match the corresponding parameter, the names do not have to match.

Therefore, the following code is perfectly valid:

void setup() {
	int xPos = 10;
    int yPos = 50;
	drawCircle(xPos, yPos);
}

void drawCircle(int x, int y) {
    circle(x, y, 30);
}

Here, the values of xPos and yPos are passed to the parameters x and y. It doesn’t matter that the variable names differ, the values are matched by position, and the parameter names are just local placeholders within the function.


🧩 Typical errors
  1. Using the same names for arguments and parameters:
void setup() {
	int score = 42;
	displayPoints(score);
}

void displayPoints(int score) {
	println("Score: " + score);
}
  1. Renaming variables unnecessarily to match parameter names:
int userScore = 10;

void setup() {
	int score = userScore;
	displayPoints(score);
}

void displayPoints(int score) {
	println("Score: " + score);
}
  1. Avoiding function calls altogether unless names match:

Learners may avoid calling functions if their variable names doesn’t match the parameter names exactly, which limits code flexibility and modularity.


🌱 Origin

This misconception may stem from a misunderstanding of how values are passed into functions.

Learners might not yet understand that parameters are local variables and that external variable names have no influence on the function’s internal naming.

Examples where arguments and parameters happen to use the same name can unintentionally reinforce this misconception by suggesting that this is required.

In addition, learners may overgeneralize from other environments (e.g. spreadsheets) where naming conventions are stricter and name matching is often necessary.


🧩 Related Exercises
7.4a) Average
Winter 2024/25

Exercise 7.4a Screenshot

7.4b) Minimum
Winter 2024/25

Exercise 7.4b Screenshot

7.4c) First/last negative number
Winter 2024/25

Exercise 7.4c Screenshot

7.4d) Create array
Winter 2024/25

Exercise 7.4d Screenshot

7.4g) Number Array with Start and Length
Winter 2024/25

Exercise 7.4g Screenshot