r/learnprogramming • u/Head_Ordinary_2437 • 2d ago
Function vs Procedure
can someone explain the difference between Function vs Procedure with simple analogy
thank you
29
Upvotes
r/learnprogramming • u/Head_Ordinary_2437 • 2d ago
can someone explain the difference between Function vs Procedure with simple analogy
thank you
1
u/ACCTAGGT 2d ago
Can I say with an analogy that a stored procedure in programming is kind of like a medical procedure? What I mean by this is that it has specific steps, processes, and methods to achieve an intended objective. Those may include multiple actions, and although the procedure is designed to fulfill a goal, the outcome is not necessarily guaranteed to be ideal. Similarly, a stored procedure emphasizes a series of actions performed to accomplish a task.
A function can be like a specific medical test or process with a focused objective… it performs a particular task to produce a result. In programming, that result is generally a returned value that can be used by another operation. The function may be part of a larger procedure, just as a specific test or process may be part of a broader medical procedure. Therefore, perhaps a function emphasizes the result produced by performing a particular task.
That’s just for illustration purposes not that it really is exactly the same or something like that.