From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sdm3C-00029y-84 for qemu-devel@nongnu.org; Sun, 10 Jun 2012 13:35:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sdm3A-0002AG-J6 for qemu-devel@nongnu.org; Sun, 10 Jun 2012 13:35:41 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:53010) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sdm3A-0002A6-EK for qemu-devel@nongnu.org; Sun, 10 Jun 2012 13:35:40 -0400 Received: by obbwd20 with SMTP id wd20so5955391obb.4 for ; Sun, 10 Jun 2012 10:35:39 -0700 (PDT) Message-ID: <4FD4DAE9.9060803@codemonkey.ws> Date: Sun, 10 Jun 2012 12:35:37 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1339097465-22977-1-git-send-email-afaerber@suse.de> <1339097465-22977-2-git-send-email-afaerber@suse.de> <4FD1530D.4010706@codemonkey.ws> <4FD4C1F3.2010203@redhat.com> In-Reply-To: <4FD4C1F3.2010203@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH qom-next 1/7] qdev: Push state up to Object List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= , qemu-devel@nongnu.org On 06/10/2012 10:49 AM, Paolo Bonzini wrote: > Il 08/06/2012 03:19, Anthony Liguori ha scritto: >>> >>> +typedef enum ObjectState { >>> + OBJECT_STATE_INITIALIZED = 1, >>> + OBJECT_STATE_REALIZED, >>> +} ObjectState; >> >> I think using a bool would be better since it reduces the temptation to >> add additional states. > > In fact someone already discussed having a third state for block > devices... :) This is *exactly* why bool is better. Because too many people will be tempted to add stuff that doesn't belong in Object. A classic problem with OO design is bloating base classes--especially when you have one common base class. Everything in Object must be relevant to all subclasses, not just some. Having an OBJECT_STATE_OPENED only makes sense for BlockDevices. Therefore the concept of opened should live in the BlockDevice parent class. Regards, Anthony Liguori > > Paolo