Acknowledgment class/device

N

.:[NeMo]:.

We assume of having a device that generically we model with the Device
class and that will be best specified with the class VCR extension of
Device.
Moreover we assume of having an application (class) Host that knows the
class Device but not VCR;
I would to make so that the device recognizes himeself (based on its
property/features) and that the class Host make an istance of VCR.
Something like
Device dev = new VCR(... pars ...);

In practical on different devices I'll have the same classes Device and
Host and moreover for everyone device I'll have a specific class
extension of Device (is VCR, PC, Freezer etc.).
The class extension could be in one specific folder.

How to make?
Also ideas, suggestions, link
thanks
 
N

.:[NeMo]:.

The idea of Abstract Factory :

http://www.castle-cadenza.demon.co.uk/abfact.htm

http://www.developer.com/java/other/article.php/626001

(nothing special)

In a class, that I call Node, I need of a way in order to obtain a
reference to one class (DeviceX) specific for host X.
(DeviceX is extension of AbstractDevice).

ex.
class Node { /* the same class on all host */
.....
AbstractDevice dev = AbstractFactory.getDevice();
^----reference to a specific class DeviceX
/* depending from host */
.....
}

On every host there will be a class (FactoryX) that it will be taken
care to assign the opportune values to the fields of DeviceX.
(FactoryX is extension of AbstractFactory).

The class Node is common to all hosts, the classes DeviceX and FactoryX
depend to the specific host:
Node (on host X) must generate an istance for DeviceX without to notice
that it uses a different class depending host.

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top