qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC] Plan for moving forward with QOM


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [RFC] Plan for moving forward with QOM
Date: Thu, 15 Sep 2011 16:33:33 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0.2) Gecko/20110906 Thunderbird/6.0.2

On 09/15/2011 04:18 PM, Anthony Liguori wrote:
I think there are two real discussions happening here.  One is how to
model and one is what is the right representation of that modelling.

I think Paolo is strongly advocating a non-OO model that uses the
command pattern to establish most of the relationships.  Maybe one level
of inheritance is used just to provide the right infrastructure for the
objects to have properties but that's inheritance for functionality
verses modelling.

I'm advocating a strict OO model.  I'm not normally a fan of OO based
design but I think it fits a device model pretty well because it's such
a concrete hierarchy.  All of the objects we create really correspond to
real world objects and the inheritance relationships are pretty darn
obvious.  When you're holding a PCI NE2000 card in your hand, there's
simply no doubt that it is-a PciDevice.

I think it's in the eye of a beholder. Hold a PCI NE2000 and E1000, they're clearly both PciDevices, but also they clearly both have PciConnectors.

Write a driver for a PCI and ISA NE2000, and then they're clearly both NE2000, but also they clearly both have an NE2K chip.

So, I don't find either model to be more or less OO. It just boils down to what you pick as your primary choice for inheritance. It is true that my model will produce a more shallow class hierarchies, but only because IMO hardware is more about composition than inheritance; that's why I am indeed advocating that relationships be established mostly by composition. (I didn't understand your reference to the command pattern, but it's probably not so important).

Secondarily, I'd hate to force a particular inheritance model, because class inheritance is a very scarce resource---you can only inherit from one class at a time.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]