Procedures with inputs VS global variables

It seems like there are a ton of global variables floating around appinventor.
So why would I need to pass inputs to a procedure? Trying to wrap my head around this.

the ap CS course create task requires a procedure with an input. i can clearly just pass my global variable as an input but this seems silly. i think i am missing an important point of when we would pass an input into a procedure instead of using a global variable but can't figure out what it is. any help would be appreciated. thanks.

Procedure parameters enable you to reuse the procedure in different contexts without having to open it up and change its code.

For example, look in

for my merge sort implementation.

The best procedures work entirely through their parameters, with no side effects.

There are places where global variables are needed, for example

  • inter-Event communication
  • a debugging trail for slow moving humans using the Do It facility

Global variables cost the coder mentally, because they don't tell you who or what has been updating them.

I recommend reading the Abelson and Sussman book in