Using an example of a component that implements an abstract data type such as a stack or a list, show why it is usually necessary to extend and adapt components for reuse.

What will be an ideal response?

Take, for example, a stack component. This will provide basic operations that are
common to all stacks such as Initialise (Create a stack), Push (an item onto the
stack), Pop (an item from the stack), Size (the number of items currently on the
stack), and perhaps others. However, each application will use stacks in different
ways and so may require different versions of these operations and additional
operations.
For example, consider a graphical browsing operation that allows users to
browse a digital library. The library is divided into areas and the identifier for each
area points to the books in that area. When the user enters an area, its identifier is
pushed onto a stack and popped from the stack when he or she leaves that area and
goes back to the previous area. Thus, the top of the stack always refers to the books
in the current area. However, there is a requirement to provide a facility where the
user can view all areas visited and this requires an additional stack operation that
provides access to all stack elements. This then has to be added to the stack
component. It also requires the Pop operation to be modified so that, when an item
is popped from the stack it is added to a ‘visited areas’ list that can be displayed in
conjunction with the current stack elements.

Computer Science & Information Technology

You might also like to view...

On the Movie Explorer's options menu, the ____________________ option displays a document's elements.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Using the Runge-Kutta method, display a table of the fraction of a radioactive material left after a certain number of years of decay. Also display the exact values using the solution y=e^(-cx)

What will be an ideal response?

Computer Science & Information Technology