Routines, methods, procedures and functions
-
reinux wrote:
People use these words interchangeably. It confuses students. How would you define them? How do they differ?
Routine and procedure I'd say mean the same thing. They are, erm, functions, that change state and do not return a value. A function is a, erm, function that returns a value and does not change state. A method is a function or procedure that belongs to a class. Note: sometimes the lines are blurred and a procedure will return a value, e.g. bool MoveNext(). And you'll have functions that do change state... I find these labels not too terribly important, but I do find it important when designing a function/procedure/method to think through what state it changes, if any, and what return value it should have, if any.
Yeah, that's how I'd define it as well.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand -
People use these words interchangeably. It confuses students. How would you define them? How do they differ?
Are you looking for just a technical definition or definitions in the English language too?
regards, Paul Watson Ireland & South Africa
Fernando A. Gomez F. wrote:
At least he achieved immortality for a few years.
-
Are you looking for just a technical definition or definitions in the English language too?
regards, Paul Watson Ireland & South Africa
Fernando A. Gomez F. wrote:
At least he achieved immortality for a few years.
Something like what Leslie provided, I think. His is pretty close to mine, but I'm just curious what other people think about it. Sorta like the difference between nerd and geek, nude and naked.
-
People use these words interchangeably. It confuses students. How would you define them? How do they differ?
I'd say... Procedure = A block of code with a name and some parameters Routine = A procedure that belongs to the global namespace Method = A procedure that belongs to a class Function = A procedure that returns a value but while speaking I tend to use only the Method/Function names.
Luca The Price of Freedom is Eternal Vigilance. -- Wing Commander IV En Það Besta Sem Guð Hefur Skapað, Er Nýr Dagur. (But the best thing God has created, is a New Day.) -- Sigur Ròs - Viðrar vel til loftárása
-
Something like what Leslie provided, I think. His is pretty close to mine, but I'm just curious what other people think about it. Sorta like the difference between nerd and geek, nude and naked.
reinux wrote:
Sorta like the difference between nerd and geek, nude and naked.
Not at all!! Originally: Either: According to Dr. Seuss the inventor of the term, a nerd is a creature for an imaginary zoo (along with a nerkle and a seersucker). Or: It was originally spelled knurd and was used in the 40's by university students to define the opposite of the partying unattentive students or "drunk"s A geek is someone who eats bugs for entertainment in a carnival. Modern times: A geek is someone who is all consumed with one particular area of expertise to the exclusion of all else particularly hygiene and a social life. I.E. a Film geek, a Star Wars geek etc. A nerd is like a geek only the area of expertise is actually many and changes regularly. A nerd is in other words a renaissance geek. And nude and NAKED are entirely different! A stripper onstage is naked but in the shower at home merely nude. As for procedures and functions and methods: Routine - (also "subroutine") is bad science fiction writer terminology most often heard in bad tv series or movies. Used by writers who don't actually care at all about the subject, they just need a plot devices to move things along. Method - hip dark-sunglasses c# coder terminology. Procedure - what your great aunt has done in the hospital. Function - C++ geek terminology. ;)
When everyone is a hero no one is a hero.
-
People use these words interchangeably. It confuses students. How would you define them? How do they differ?
Routines can become boring. Methods may involve madness. Procedures might rip your guts out. Functions will occasionally misfunction.
-
People use these words interchangeably. It confuses students. How would you define them? How do they differ?
The words routine, method, and procedure are not used by Stroustrup in connection with subroutines. The only word he uses in this regard is function. You can check this by looking in the index to The C++ Programming Language. You can look at the specs for other languages to see what is correct for them.
Best wishes, Hans
[CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]
-
reinux wrote:
Sorta like the difference between nerd and geek, nude and naked.
Not at all!! Originally: Either: According to Dr. Seuss the inventor of the term, a nerd is a creature for an imaginary zoo (along with a nerkle and a seersucker). Or: It was originally spelled knurd and was used in the 40's by university students to define the opposite of the partying unattentive students or "drunk"s A geek is someone who eats bugs for entertainment in a carnival. Modern times: A geek is someone who is all consumed with one particular area of expertise to the exclusion of all else particularly hygiene and a social life. I.E. a Film geek, a Star Wars geek etc. A nerd is like a geek only the area of expertise is actually many and changes regularly. A nerd is in other words a renaissance geek. And nude and NAKED are entirely different! A stripper onstage is naked but in the shower at home merely nude. As for procedures and functions and methods: Routine - (also "subroutine") is bad science fiction writer terminology most often heard in bad tv series or movies. Used by writers who don't actually care at all about the subject, they just need a plot devices to move things along. Method - hip dark-sunglasses c# coder terminology. Procedure - what your great aunt has done in the hospital. Function - C++ geek terminology. ;)
When everyone is a hero no one is a hero.
John C wrote:
And nude and NAKED
Yeah, naked requires an observer. You may be sunning yourself nude in your backyard and suddenly find yourself naked when a neighbour greets you over the fence.
John C wrote:
When everyone is a hero no one is a hero.
Or, from Gilbert and Sullivan's, "The Gondoliers" -- "When everyone is somebody then no one's anybody."
-
Potato, potato.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
you pronounced them the wrong way round.
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist -
The words routine, method, and procedure are not used by Stroustrup in connection with subroutines. The only word he uses in this regard is function. You can check this by looking in the index to The C++ Programming Language. You can look at the specs for other languages to see what is correct for them.
Best wishes, Hans
[CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]
That is also true of B and C, going by early Bell Labs documents that are available online.
-
you pronounced them the wrong way round.
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighistAussies... :rolleyes: ;)
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
People use these words interchangeably. It confuses students. How would you define them? How do they differ?
Routine, n., a set of instructions executed to perform a specific task. Subroutine, n., a routine invoked in some fashion from another routine, with a mechanism to return control to the calling location when the subroutine has finished. Subroutines may be referenced by address, line number, or a symbolic name depending on the language and system in use. Procedure, n., see Routine Function, n., a subroutine, invoked by name, that returns a value but does not otherwise alter the state of the system. Also another name for a subroutine in C and C-like languages. Method, n., in Object-Oriented Programming: a subroutine, invoked by name and context (object). Methods are generally used to retrieve information about the context object, or to modify it in some way, although they may do neither, instead acting as functions (in OO systems that do not provide a means of defining functions, this practice may be used to simulate them).
-
Been eating lots of beans today, I see.
No, as others have said, a method, and a procedure are the same thing. Even a function is the same thing, if it's inside a class, it's a *member* function. And a routine, I've not heard them called that by anyone for a long time.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
John C wrote:
And nude and NAKED
Yeah, naked requires an observer. You may be sunning yourself nude in your backyard and suddenly find yourself naked when a neighbour greets you over the fence.
John C wrote:
When everyone is a hero no one is a hero.
Or, from Gilbert and Sullivan's, "The Gondoliers" -- "When everyone is somebody then no one's anybody."
My Performing Arts prof would argue differently :) He'd say that a nude figure is objectified. Not that I agree with much of what he says...
-
People use these words interchangeably. It confuses students. How would you define them? How do they differ?
reinux wrote:
How do they differ?
Not different at all as all the others have said.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
-
Routine, n., a set of instructions executed to perform a specific task. Subroutine, n., a routine invoked in some fashion from another routine, with a mechanism to return control to the calling location when the subroutine has finished. Subroutines may be referenced by address, line number, or a symbolic name depending on the language and system in use. Procedure, n., see Routine Function, n., a subroutine, invoked by name, that returns a value but does not otherwise alter the state of the system. Also another name for a subroutine in C and C-like languages. Method, n., in Object-Oriented Programming: a subroutine, invoked by name and context (object). Methods are generally used to retrieve information about the context object, or to modify it in some way, although they may do neither, instead acting as functions (in OO systems that do not provide a means of defining functions, this practice may be used to simulate them).
-
No, as others have said, a method, and a procedure are the same thing. Even a function is the same thing, if it's inside a class, it's a *member* function. And a routine, I've not heard them called that by anyone for a long time.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Christian Graus wrote:
And a routine, I've not heard them called that by anyone for a long time.
Have you stopped programming in FORTRAN?
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
People use these words interchangeably. It confuses students. How would you define them? How do they differ?
For me, it's programming language dependent: Routine: Only for assembly language, FORTRAN, and command line batch files. Yes, I consider batch files programming, at least for purposes of this discussion. Method: C++ functions within a class, or COM methods within an interface. I don't C# (I'm near-sighted) or Java, but I imagine they're equivalent. Procedure: Pascal or Ada; any language that distinguishes between routines that return a value and those that don't. Procedures don't return a value, and can't be used on the right hand side of an assignment. Function: C/C++, or any language where a piece of code returns a value that can be used in a right hand side expression.
Software Zen:
delete this;
Fold With Us![^] -
Christian Graus wrote:
And a routine, I've not heard them called that by anyone for a long time.
Have you stopped programming in FORTRAN?
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
I skipped that entirely. Thankfully.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
You forgot
lambda
;Pxacc.ide - now with IronScheme support
IronScheme - 1.0 alpha 1 out now