Patterns covered so far in class:
Singleton, Factory, Abstract Factory
Prototype, Composite
Flyweight, Proxy, Facade
Adapter, Bridge, Decorator
Chain, Mediator
Command, Template, Strategy, Memento
Observer
Here are the requirements for the online voting system. You are to produce a design for this system, using OO design patterns. Prepare your materials on a web page and submit the URL by the due date, Apr. 22 midnight.
You will present your design and give the rationale for it in class starting Thursday Apr. 23, and finishing Tuesday Apr. 28.
The design should be explained as a collection of class/object diagrams (as the design patterns are expressed in), with interfaces defined at a top level (important methods and fields, but not necessarily full details). Show where the patterns involved are, list them and explain what part of the system functionality they are providing. Give your rational... why did you choose certain patterns and structures, and reject others? Be prepared to explain your design decisions.
Use the stack code you wrote before. Write an application that will allow a stack object to be manipulated, using input commands from the command line or from keyboard input (your choice). Make your stack do these operations:
push (an integer) pop top (return int) empty (returns boolean) size (returns int) snap make a memento-based snapshot of the state contents undo use the memento to restore the stack to the saved state
You can add other operations as you wish or need
The application will serve as the custodian here... since it is taking the commands from the input/interface, it knows when the memento is needed for saving and storing state. When the snap command is seen, it will as the Stack for a memento and keep the memento until an "undo" is seen. It will then give the memento back to the stack for using.
The stack object is the Originator. It creates the Memento (when asked by the caretaker) and send the Memento to the Caretaker. It also receives a Memento from the Caretaker and uses it to re-load its state (when requested to do so by the Caretaker).
So you need 3 classes (at least): Originator (Stack), Caretaker (main class), and Memento.
CRC cards due for the online voting system.
Develop your CRC cards as cards, physically, after you have completed your Use Cases. After you are done creating the cards, transcribe them into a document that I can view remotely. It is important to follow the procedure of physically doing cards to create them, and transcribe after.
A9Develop USE cases for the online voting system.
Create a URL for the entire project. You will submit this URL for this assignment, and it will contain the Use Cases and CRC cards. Later you will add to that URL the other parts of the design project.
Develop the USE cases as a document (Word, PDF, HTML, whatever you like). I want you to have this done for Tuesday class because I want to discuss the remaining patterns in the context of how each might be used in the system design.
A8This assignment has two parts
1) Starting with the Stack adapter program we looked at in class (StackDemo.java, the one that creats a Stack as an adapter class on the built-in Java Vector class), create a second adapter class that implements a Queue. I want you to adapt Stack with the Queue class. Use object adapter to do this (class adapter requires multiple inheritance). Do this by first adding a method "reverse" to the Stack class. Then you will be able to more easily use Stack to implement the behavior of a Queue.
2) Using the program BridgeDemo.java that we studied in class, add a new front end
Stack abstraction. The program as I gave it to you has two stack abstractions...
vanilla stack, and hanoi stack. Add a third: bubble stack, the behavior of which we
studied back in the ADT part of class. A bubble stack has non-traditional push behavior.
If you push as item onto a bubble stack, and that item value is already in the stack,
then it is removed from where it is and put on top.
Also add a third backend implementation class. Make this implementation on top of the
Java Hashtable class. Change the main program to exercise
all 3 front end abstractions with all 3 of the back end implementations.
Using the flyweight Java program as an example (the one with the window containing an array of buttons), and the proxy Java program (sets up a net socket and two of them talk over it), modify these to have each button communicate via proxy with a server process across the network.
The idea is to be able to get, from clicking each button, two kinds of information:
a) one kind is context-specific information (i.e., related to, or a function of, it (x,y) position in the grid) but this information must be computed from a remote process. b) The other kind of information also has to be computed remotely, but once computed for a button type, it will remain the same for all buttons of that type. Moreover, we don't want to compute all this information if it is never requested.
We will get these two kinds of information by either a left-click on a window button (giving information type a) or a right-click (giving information type b)
So you create one or more proxies . A proxy is talked to when a cell is clicked. If this is the first time a button of this type has been clicked, the proxy goes remote and computes the context specific information, and the one-shot information. It caches the one-shot information so that future button clicks on the same type will not require recomputation (should this be cached in the proxy? or is it best cached as additions to the intrinsic information for each flyweight?).
Lets have 2 types of button clicks... left mouse, and right mouse. Left mouse will request the (x,y) specific information for the button. Right click will request the one-shot information... so left click will always require a remote access via the proxy. Right click will only require remote access for the first such click on a button of each type.
You are free to decide what specific functions the remote server process will be computing from the button information sent to it. You are also free to decide if it is a better design to use one proxy that all buttons talk to, or if you need a different proxy for each button type, or if you need a proxy for type (a) information and another for type (b). You might choose either way, depending on what kind of information is being computed at the remote server, and how that information in employed in the client (window) process.
A6
(due 03/02/09 Mon 11:59pm)
(via blackboard)
Team work.
Each member of the group will submit a solution via blackboard,
but the work will be jointly done.
Produce a program in Java or C++ that uses factories, an abstract factory to gen them, and a composite pattern to do something. I dont care what it does... use the example Java code we have done in class as a guide for the complexity I am looking for here. Make your composite inter have at leasat two common methods (2 or more methods that are provided by both inner and leaf nodes).
A5
(due 02/27/09 Fri 11:59pm)
(via blackboard)
Create a webpage where you will put your answers to the pattern discussion questions. You will add answers as we cover them in class. Submit the URL of your webpage via BlackBoard.
A4
(due 02/16/09 Mon 11:59pm)
(via email to "stotts" title "COMP 723 A4")
Practice lamdba-calculus with the following problems. 1. Define a lambda-expression that implements an XOR function and express it in ML. To do this, create a decision tree using the IF (conditional) form in your notes (here). Here are some notes about doing this with ML, a typed notation. Show that your XOR works for all the cases, or show which ones it does work for. Here is a single file containing ML encodings for the Church numerals and basic booleans of lambda calculus. 2. Define a lambda-expression (expressed in ML) that implements a NAND function, also with the IF (conditional) form. Demonstrate that it works correctly. 3. Use your NAND expression to define the OR function, and compare your expression to the one we did in class: OR == Lx Ly (( x T ) y ) 4. Create a lambda expression that will lengthen endlessly as it is reduced (in other words, it has no normal form). Do this in pencil notation (not ML) and show a reduction to demonstrate that it lengthens and leaves a form that continues to need reduction.
A3
(due 02/09/09 Mon 11:59pm)
(via email to "stotts" title "COMP 723 A3")
Use ML to express the axioms you write. Using ML will also allow you to check the behavior to see if you have expressed what you intended.
Using Guttag's hueristic, give consistent and complete algebraic specs for this ADT (class):
LIB (library) new: --> LIB add: LIB x BOOK --> LIB rem: LIB x BOOK --> LIB cko: LIB x BOOK x PERSON --> LIB cki: LIB x BOOK x PERSON --> LIB wait: LIB x BOOK x PERSON --> LIB off: LIB x BOOK x PERSON --> LIB has: LIB x BOOK --> boolean here: LIB x BOOK --> int num: LIB x BOOK --> int new makes a LIB with no books, no wait lists, etc. add puts another copy of a book in the library rem takes a copy out of the library cko allows a person to check out the book cki checks the book back in; if there is a person on wait list it does a cko to that person. wait puts person at the back of a waiting list for a book off takes a person out of the waiting list for a book has tells if a book exists in the Library (even if all copies are checked out here tells how many copies of a book are available for checking out num tells how many copies total of a book exist in the libraryYou can use string for PERSON. Use int for BOOK (like a simplified ISBN).
A2
(due 02/02/09 Mon 11:59 pm )
(via email to "stotts" title "COMP 723 A2")
A1
(due 01/15/09 Sun 11:59 pm )
(via email to "stotts" title "COMP 723 A1")
Answer this question: What is software design?
I am not looking for pages, but I would like you to give it enough thought that you can answer with a good paragraph or two. Prepare this answer for the next class. Email it to me by the time I have indicated so I can take a look before the next class, and so you will be prepared to discuss this next time.