O
Orgun
Hi,
I sent this message to the moderated c++ group too but it is
waiting for moderator approval and I wanted to send here too.
I am new to Design Patterns. I want to write a simple
DeviceManager which is only interested in CD/DVD devices. I want to get
the list of CD/DVD devices and "be informed when a disc inserted into a
device". I am developing this on Linux. So, I used HAL API and read
some system (actually /proc) files to gather required information.
Everything is OK so far. But, at the same time, I want to visualize
this information. I have a dialog which lists the CD/DVD devices and
according to the chosen device it shows the media it contains (says
empty if it has none) To visualize this information I need to notify
the GUI part. Therefore I decided to use "Observer" design pattern.
However, my DeviceManager must be a "Facade" to hide the implementation
details (because, in fact, I used another class to read those system
files). Worse, DeviceManager itself must be an "Observer" to get the
information from the HalHandler to be informed when a new media
inserted or removed.
GUI ("Observer" for DeviceManager)
I
I
Device manager ("Subject" for GUI, "Observer" for HALHandler and must
be "Facade" too)
/ \
/ \
FileOp HALHandler ("Subject" for DeviceManager)
My questions are as follows:
a) Is applying multiple design pattern to a single class
acceptable/normal or does it indicate a wrong design? Because, if I am
not wrong, applying two or more design pattern to a single class may
necessitate multiple inheritance (which might make everything much more
complex than expected)
b) If my design is problematic or wrong what would be the correct
solution/design? Any suggestions/ideas???
Thanks everybody in advance
I sent this message to the moderated c++ group too but it is
waiting for moderator approval and I wanted to send here too.
I am new to Design Patterns. I want to write a simple
DeviceManager which is only interested in CD/DVD devices. I want to get
the list of CD/DVD devices and "be informed when a disc inserted into a
device". I am developing this on Linux. So, I used HAL API and read
some system (actually /proc) files to gather required information.
Everything is OK so far. But, at the same time, I want to visualize
this information. I have a dialog which lists the CD/DVD devices and
according to the chosen device it shows the media it contains (says
empty if it has none) To visualize this information I need to notify
the GUI part. Therefore I decided to use "Observer" design pattern.
However, my DeviceManager must be a "Facade" to hide the implementation
details (because, in fact, I used another class to read those system
files). Worse, DeviceManager itself must be an "Observer" to get the
information from the HalHandler to be informed when a new media
inserted or removed.
GUI ("Observer" for DeviceManager)
I
I
Device manager ("Subject" for GUI, "Observer" for HALHandler and must
be "Facade" too)
/ \
/ \
FileOp HALHandler ("Subject" for DeviceManager)
My questions are as follows:
a) Is applying multiple design pattern to a single class
acceptable/normal or does it indicate a wrong design? Because, if I am
not wrong, applying two or more design pattern to a single class may
necessitate multiple inheritance (which might make everything much more
complex than expected)
b) If my design is problematic or wrong what would be the correct
solution/design? Any suggestions/ideas???
Thanks everybody in advance