Keywords: current

Next: 2.1.7.3 The Iterator Pattern Up: 2.1.7 Extended Mutable Lists Previous: 2.1.7.1 Formulating Traditional Linked

### 2.1.7.2 Spaghetti References (akin to spaghetti code)

We strongly endorse the slogan "pointers are the root of all evil." In the 1970s, structured programming was developed, which placed a discipline on the control flow of programs. Up until that point, languages (and programmers) had been very liberal in their use of the notorious `goto` statement or unconditional branch. Undisciplined use of `goto` statements to programs whose control flow is almost impossible to trace by hand (spaghetti code), and which are hence almost impossible to debug. In his Turing Award Lecture in the early 1970s, C.A.R. Hoare asserted that multiple references to the same data in a program can introduce a similar form of complexity if that data can be mutated through those references. With multiple references to mutable data in a program, we can stumble into serious trouble when one part of our program modifies an object when another part is unaware of or unprepared for the modification.

Even in programs written and maintained by a single programmer, the unrestricted use of pointers is foolhardy and invites disaster. A programmer almost certainly does not remember the precise reasoning used involved in writing every section of a significant application. As a result, mistakes are inevitable. Just as structured programming placed constraints on the control flow in programs, we will place constraints on when and where mutable data can be changed. This is why we hide mutable nodes inside a list container.

Next: 2.1.7.3 The Iterator Pattern Up: 2.1.7 Extended Mutable Lists Previous: 2.1.7.1 Formulating Traditional Linked