Step 1: Understanding the requirements, inputs, and outputs

Regardless of how your requirements are written (or even if they are only in your mind), they include three parts. First is what the program/method must do: its business rules. Second, the program receives data as inputs. Inputs are a fundamental part of our reasoning, as it is through them that we can test the different cases. Third, reasoning about the output will help us better understand what the program does and how the inputs are converted to the expected output.

For the substringsBetween() method, my reasoning would be

  1. The goal of this method is to collect all substrings in a string that are delimited by an open tag and a close tag (the user provides these).
  2. The program receives three parameters:a) str, which represents the string from which the program will extract substringsb) The open tag, which indicates the start of a substringc) The close tag, which indicates the end of the substring
  3. The program returns an array composed of all the substrings found by the program.

Such reflection is useful to think about what you want from the method.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *