Lab 5: Linked List Enhancements | CS 61BL Summer 2024
In today’s lab, we’re going to continue our discussion of linked lists by introducing a new way of organizing programs through encapsulation. By hiding our linked list behind an abstraction barrier, it will no longer be naked and will be more user-friendly. We will first define a few terms. The “namke” implementation of IntList that we learned fom Lab 4 is impractical to use at scale. In it, the idea of a node in the list and the list itself are not separate. This means that someone who wants to use the IntList class would need to spend a lot of time adding null checks and handling errors that might come as a result of accidentally or intentionally modifying the item or next of a list. By giving users direct control to the IntList data structure’s internals, in some ways, we’ve actually made it harder to reason about the correctness of a program. We want to separate the idea of the list as an entity from an entry in the list, much like an abstraction barrier. We’ll see that this design
In today’s lab, we’re going to continue our discussion of linked lists by introducing a new way of organizing programs through encapsulation. By hiding our linked list behind an abstraction barrier, it will no longer be naked and will be more user-friendly. We will first define a few terms. The “namke” implementation of IntList that we learned fom Lab 4 is impractical to use at scale. In it, the idea of a node in the list and the list itself are not separate. This means that someone who wants to use the IntList class would need to spend a lot of time adding null checks and handling errors that
Explore this link on the map →