using the composition pattern we wish to implement favorites list by making use of positionallist for storage if elements of the positional list were simply elements of the favorites listwe would be challenged to maintain access counts and to keep the proper count with the associated element as the contents of the list are reordered we use general object-oriented design patternthe composition patternin which we define single object that is composed of two or more other objects specificallywe define nonpublic nested classitemthat stores the element and its access count as single instance we then maintain our favorites list as positionallist of item instancesso that the access count for user' element is embedded alongside it in our representation (an item is never exposed to user of favoriteslist class favoriteslist """list of elements ordered from most frequently accessed to least "" nested item class class itemslots _value _count streamline memory usage def init (selfe)the user element self value access count initially zero self count nonpublic utilities def find position(selfe) """search for element and return its position (or none if not found"" walk self data first while walk is not none and walk elementvalue ! walk self data after(walk return walk def move up(selfp) """move item at position earlier in the list based on access count ""consider moving if !self data first) cnt elementcount walk self data before(pmust shift forward if cnt walk elementcount while (walk !self data firstand cnt self data before(walkelementcount) walk self data before(walkdelete/reinsert self data add before(walkself data delete( )code fragment class favoriteslist (continues in code fragment