| UMBC | CSEE | Tarr | CS491D |
1) Select a pattern (other than Singleton) and discuss its potential uses, advantages and disadvantages.
2) The following patterns were listed as reducing tight coupling: Abstract Factory, Facade, Observer. Select one of these patterns and discuss how the pattern reduces coupling.
3) What is the Open-Closed Principle? Give an small code example which illustates the principle.
4) An indexed web page consists of a title and a list of label-URL pairs (the label is what is written on the web page, the URL is what is followed when the user selects that label). An indexed web page must support an operation to display itself (but might support a variety of other operations as well). We would like to be able to display a particular indexed web page in a variety of formats, including (but not limited to) a left-aligned, bulleted list of items; a centered, bulleted list of items; and a two-column table, where each column contains a bulleted list of items. We have several design constraints. First, clients should be able to have a particular indexed web-page object display itself using different layouts at different times. Second, because displaying a list of indices is likely to be useful in other, more complex, types of web page classes, we want to be sure that we can easily reuse the code that accomplishes this task in other places.
Select the most appropriate design pattern to use to address the problem and show how it is applied. In particular, show an appropriate class diagram(s) and enough code fragments to illustrate your use of the pattern to solve the problem.
5) A menu consists of a set of choices and a mechanism for a user to specify which choice they want. There are a variety of styles of menus. One menu style is to print a number in front of each string (e.g., 1, 2, and so on) and the let the user enter a number to make a choice. Another menu style prints a letter in front of each string (e.g., A, B, and so on) and lets the user enter a letter to make a choice. Still another menu style prints each string out, and lets the user type in the first few characters of the string to make that choice. In general, all of the menus must provide a way to add entries to the menu, delete entries, display the menu, and obtain the user's choice.
Note that each menu style requires slightly different information when it's created (the "numeric" style requires the starting number to use, such as 0 or 1; the "letter" style requires the starting letters, and whether the letters should be capitalized; and so on).
We have several design constraints. First, although an individual application may have many different menus, they should all be in the same style (e.g., in a given application every menu should be "numeric" or it should use "letters", and so on). Second, a client using this framework should should be able to create menus, add entries, and so on, without ever being aware of the specific menus they are working with. Finally, it should be extremely easy for us to modify the program so that it uses a different menu style.
Select the most appropriate design pattern to use to address the problem and show how it is applied. In particular, show an appropriate class diagram(s) and enough code fragments to illustrate your use of the pattern to solve the problem.
|
Bob Tarr University of Maryland, Baltimore County tarr@umbc.edu | UMBC | CSEE | Tarr | CS491D |