What is the difference between routine , method , procedure , function ? please explain it with example?

发布时间:2017-6-25 21:57:12 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"What is the difference between routine , method , procedure , function ? please explain it with example? ",主要涉及到What is the difference between routine , method , procedure , function ? please explain it with example? 方面的内容,对于What is the difference between routine , method , procedure , function ? please explain it with example? 感兴趣的同学可以参考一下。

What is the difference between routine , method , procedure , function ? please explain it with example?

  a method is named and attached to an object. so, for example, a method is like a function but is contained inside a class. its scope is limited to that class, and cannot affect variables outside that class, even global variables. if you need to affect a variable outside of a class, just use a function (or routine) that is not contained in a class. 

a function is named and returns a value. 

a routine is like a function but does not need to return a value. 

a procedure is named and may or may not return a value, but receives parameters. 

i think the distinctions between a function and a routine are sort of old school. i don't think that distinction is important anymore. 

so a function is like 
function addOne(n) { 
  return n++; 


routine is like 
function doStuff(){ 
  makeStuffHappen(); 


and a method is like 
thing.destroy(){ 
  thing.destroyed = true; 


a procedure is like 
makeApples(x){ 
  makes x apples 



edit: typos and made bad examples>.<;

上一篇:@RequestBody
下一篇:广商14级软件工程团队第三次冲刺相关问题

相关文章

相关评论

本站评论功能暂时取消,后续此功能例行通知。

一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本站制作、复制和传播不法有害信息!

二、互相尊重,对自己的言论和行为负责。

最近更新