Re: Applying multiple design paterns to a single class



Sorry for silly spelling mistake,

Your assumption is write, Even (new) linux kernel is written in C &
it should be "right" instead of "write".

--RGS


raxitsheth2000@xxxxxxxxxxx wrote:
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.


Your assumption is write, Even (new) linux kernel is written in C &
Assembly,it provide you the same observer-like(pub-sub) (hey what is
module from linux kernel perspective ? Isn't it pub-sub ? ) facility
(using C-API callback or Broadcast) ,


http://www.redhat.com/magazine/003jan05/features/hal/

(even the feature described here is of specific Vendor and Specific
version, i am assuming the basic simillar functionality is available in
simillar kernel, Plz chkout with your kernel version and your vendor(if
any) )



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 have to agree i have not given direct answer :)

Cheers
Raxit Sheth

.