Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Consider the following points:</p> <ol> <li>You have a function that displays a list of items and lets you pick an item from the list.</li> <li>If you call function <code>A()</code> from within function <code>B()</code>, when you finish executing the code in <code>A()</code>, then the default program flow resumes in <code>B()</code>.</li> <li>What happens if choosing a menu item in <code>main()</code> calls another function <code>submenu()</code> that displays its own list of items? What would happen in the program flow if you finished executing <code>submenu()</code> and returned to <code>main()</code> when the user hits the Enter key)?</li> </ol> <hr> <p>Using separate functions to represent submenus is a workable solution, but it probably isn't the best practice. There's a lot of copying and pasting to handle the menu 'mechanics' (displaying the basic menu, indicating highlighted choice, etc) in each function, which can lead to issues with fixing bugs and maintaining this code over time - if there's a bug in how one menu displays, you have to go through all the menu functions you've created and fix the bug in each one of them.</p> <p>If you wanted to consolidate this down into a more compact and maintainable approach, there are some things you might want to think about:</p> <ul> <li>What you are doing is displaying a List.</li> <li>The List you're displaying is a series of Items.</li> <li>Each Item might contain a List of its own, or possibly just text to display, or even a pointer to another function.</li> </ul> <p>How would you build a function to display and interact with this kind of List object?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload