Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to explain method calls?

let's consider a small method:

int MyFunction(string foo, int bar)
{
  ...
}

and some calls:

MyFunction("",0)
int x = MyFunction(foo1,bar1)

How would you explain this to a non-technical persons? Has anybody a nice metaphor?

I tried to explain method calling (or function application) several times, but I failed. Seems I can't find the right words here.

Regards, forki

UPDATE: It is important for me to explain how the parameters are passed / matched.

like image 541
forki23 Avatar asked Jan 19 '26 08:01

forki23


2 Answers

(Highly non-technical solution)

It's like making an order:

  • Calling the method = dialing the right number
  • Passing the arguments = giving your details
  • the method does is job
  • Getting a return value = getting what you ordered
like image 55
Amirshk Avatar answered Jan 21 '26 09:01

Amirshk


You could tell function is a process available into an object that could be called by other. Lets say "You" is an object with function "Work". Your "Boss" is the caller object. Your Boss then can call you to Work with different type (which is parameter).

In the end Your "Boss" can ask "You" to Work("encode this") or Work("check email") or Work("finish deadline"), etc.

like image 35
Jojo Sardez Avatar answered Jan 21 '26 07:01

Jojo Sardez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!