0
$\begingroup$

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.

$\endgroup$
2
  • 1
    $\begingroup$ 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. $\endgroup$
    – quintumnia
    Jul 27, 2018 at 17:13
  • 1
    $\begingroup$ This is actually an English question. $\endgroup$ Jul 28, 2018 at 21:55

3 Answers 3

1
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.