From the course: Programming Foundations: Design Patterns
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Understanding the Iterator pattern
From the course: Programming Foundations: Design Patterns
Understanding the Iterator pattern
- [Instructor] As we've seen, we've got two menus with two different implementations. One uses an Array, and the other uses an ArrayList. That means that the class responsible for printing the menus, the cafe, needs to use two different methods of entering through the menu items. So the two menus are exposing the details of how they're implemented to the cafe, which means that the cafe is dependent on those implementations. If someone decides to change the implementation of a menu, or say, add another type of menu, or say, add another type of menu, that will require code changes to the cafe. that will require code changes to the cafe. We can reduce the dependency between the cafe We can reduce the dependency between the cafe and the menu implementations by using the iterator pattern. and the menu implementations by using the iterator pattern. Here's the definition for iterator pattern. Here's the definition for iterator…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Encapsulating iteration1m 44s
-
(Locked)
Understanding the Iterator pattern2m 28s
-
(Locked)
Using the Iterator pattern3m 36s
-
(Locked)
Using built-in iterators1m 19s
-
(Locked)
The single responsibility principle1m 20s
-
(Locked)
The iterator pattern as language feature1m 30s
-
(Locked)
Challenge: The Iterator pattern57s
-
(Locked)
Solution: The Iterator pattern36s
-
(Locked)
-
-