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...

Answer the following statements true (T) or false (F)

1. Consider this operator overloading for class Money, modified from Display 8.1 by omitting the const modifier on the return type:Is the following expression legal? If legal, what could it mean, and where does theinformation that is assigned go? ``` Money m1(17.99), m2(23.57) m3(15, 22); (m1 + m2) = m3; ``` 2. C++ allows overloading of the function application operator ( ). Explain. 3. A friend function has access only to the private members and member functions of the class (and all objects of that class) of which it is a friend. 4. A class can have friends that are functions as well as friend classes.

Computer Science & Information Technology

The ________ is a financial measurement that is used to evaluate an investment

Fill in the blank(s) with correct word

Computer Science & Information Technology

A JTabbedPane

a. arranges GUI components into layers such that only one layer is visible at a time. b. allows users to access a layer of GUI components via a tab. c. extends JComponent. d. All of the above.

Computer Science & Information Technology

When entering data into a table, pressing the ________ key(s) moves to the next field

A) Ctrl and Tab B) Shift and Tab C) Tab D) Alt and Tab

Computer Science & Information Technology