# What is the difference between “use case” and “function”?

In the use case diagram, we draw use cases as an ellipse. Are the use cases the same as functions? I mean by functions, those functions which we write in the program.Thank you in advance.

• Use case enable you to visualize the different types of roles in a system,however,a function defines a procedure or routine. Some programming languages make a distinction between a function, which returns a value, and a procedure, which performs some operation but does not return a value. – quintumnia Jul 27 '18 at 17:13
• This is actually an English question. – Yuval Filmus Jul 28 '18 at 21:55

If by "function" you mean functionality then a single use case may require more than one function to achieve and a single function may serve multiple use cases.

Here's a concrete example:

Use case:

• Allow user to withdraw money

Functions:

• Check user balance
• Prompt user to enter amount and check against balance
• Check amount against money in machine
• Output money

Depending on how you go about documenting your design you can argue that the 4 functions above can be written as a single function. Though doing this misses the important realization that Check user balance is a function that can be reused in another use case (Allow user to see his balance), even if we reduce them to one function the use case and function would be different ways to say the same thing:

Use case:

• Allow user to withdraw money

Function:

• Withdraw money

So, at its core level a functionality is an implementation of processes for a use case.

Why do we need two different names? Sometimes it makes it clearer to talk about a requirement and the solution to it. Similar to how in programming we have classes and objects.

The word function has several meanings. One of them is similar to the meaning of use case. Another is mathematical function. Yet another is computer routine. Wiktionary lists a few more.

From my experience use case is what the code is used for and function is what the code does. For example you may have a subroutine that calculates the length of the minnimal path between two nodes in a graph but a specific use case may be to find the minimal length between two points in a maze (when represented as a graph).