Discuss the bag collection framework, which consists of the following classes: I
ID: 3782971 • Letter: D
Question
Discuss the bag collection framework, which consists of the following classes:
Indentation in this group represents interface implementaion:
BagInterface
....ArrayBag
....LinkedBag
Indentation in this group represents inheritance:
AbstractCollection
....AbstractBag
........ArrayBag
............ArraySortedBag
........LinkedBag
Where are the more general (abstract) classes?
Where are the more specific (concrete) classes?
What are the benefits of this organization?
Does it have any detriments?
Can you think of any other bag classes that should be added to this class hierarchy?
Does AbstractBag implement BagInterface?
Why or why not?
What does this mean?
Why is there a __str__ method in both AbstractCollection and AbstractBag?
What is different about them?
What is the reasoning/motivation behind this difference?
Why is there an __eq__ method in both AbstractCollection and AbstractBag?
What is different about them?
What is the reasoning/motivation behind this difference?
.
Explanation / Answer
Bag collection is collection of data structure which are used to store items with multiple occurence and their count.
ArrayBag is an array based implementation while LinkedBag is a linkedList based implementation.
Where are the more general (abstract) classes?
More general classes are in AbstractBag
Where are the more specific (concrete) classes?
More specific implementation are in ArrayBag, ArraySortedBag, LinkedBag
What are the benefits of this organization?
With this organization it is easier to implement new specific use case of bag.
Does it have any detriments?
Yes. If implementation of any of the implemented method of AbstractBag (in AbstractBag) change then full hierarchy needs to be re-evaluated.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.