Sample Final Q3

10 views
Skip to first unread message

montse

unread,
Apr 23, 2011, 10:12:04 PM4/23/11
to UBC CPSC 210
Hi,
Question 3 of the sample finals asks to choose a design pattern and
the solution suggests the Decorator Design Pattern. However, I'm
wondering if it would work if I use the output written to a file/
string as an object, and instead use the Factory Design Pattern. Where
I create two abstract classes: CompressedOutput and EncryptedOutput
which use the output of the Writer subclasses. Then, each Writer
subclass would have dependencies on subclasses of the abstract classes
(ie. CompressedOuptutString, EncryptedOutputString, same for file), so
that it is up to StringWriter and FileWriter to create either objects.

Thanks,
Montse

Paul Carter

unread,
Apr 24, 2011, 6:50:51 PM4/24/11
to ubc-cp...@googlegroups.com
I'm finding it a bit hard to figure out what exactly you have in mind. Note that at the end of my solution I included a small code segment to illustrate how I would write compressed output to a file given the application of the Decorator Design pattern. Could you do something similar with your design to give me a bit more information about what you have in mind?

It's too bad we can't include diagrams in messages posted to the Google group...

Paul

montse

unread,
Apr 24, 2011, 9:13:21 PM4/24/11
to UBC CPSC 210
Could I bring my design to tomorrow's office hours?
Thanks,
Montse

Paul Carter

unread,
Apr 24, 2011, 9:32:36 PM4/24/11
to ubc-cp...@googlegroups.com
Sure. It would be useful to look at a UML class design diagram.

Paul

Reply all
Reply to author
Forward
0 new messages