[Spice-devel] Using private structure for making structure more public...

Christophe Fergeau cfergeau at redhat.com
Fri May 13 13:27:32 UTC 2016


On Fri, May 13, 2016 at 04:42:08AM -0400, Frediano Ziglio wrote:
> Hi,
>   this is the last though looking at refactory branch current trend.
> 
> We use Gobject and private separation so structure are less exposed
> to external... bla bla bla.
> 
> The implementation however looks to not agree with it!
> 
> Usually the channel and the client (like InputsChannel and 
> InputsChannelClient) are quite tight so each other know and access
> their internal. This could lead to bad encapsulation. So current
> status is:
> - single file for channel/client (beside display which is
>   huge and split in different files);
> - access mostly free from one structure to another. Which is
>   bad.
> So the actual transformation is:
> - split channel and client;
> - add accessors to deal with encapsulation;
> - move structures to headers;
> - change structures to Gobjects
> The result however from the external point of view is that
> users of channels include these giant headers with a lot
> of internal details while before in headers there were very
> small information, mainly you have these structures (without
> any types beside base class) with these methods.
> 
> The most visible example of this is CursorChannel(Client).
> These have (currently master state) very limited header (one!)
> while at the end it's quite huge.
> 
> Now... from the abstract point of view. Why a client of a channel
> have to know details on the client of the same channel?
> I think it's just a design mistake (at lest mostly).
> 
> Back to code it's quite a mistake that channel headers include
> client ones, should not. Would be also better to have a kind of
> external interface header and a specific channel <-> specific client
> header to avoid exposing all accessors.

I haven't looked at the Channel/Client case in particular, but
the general plan is indeed to go from one huge file with everyone
accessing any structure to split files with structures in headers when
needed (which is mostly accomplished by now).
Then what we are trying to do now is to add some common
structure/encapsulation to all of this, through some object model
(gobject) and private data. The expectation is that it will remove more
interdependencies between C files. Maybe this is not what is happening
right now with Client/Channel, but the expectation is that with less
poking at internal structures, it will be easier to do more decoupling,
and to think about the overall design. So it's very likely/not
unexpected that some design improvements can be found.
If some patches are a big step backward from a design perspective, it's
worth raising this during review, otherwise my hope is that even if
things are not perfect, we are still making progress towards something
saner.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160513/36bdf96c/attachment.sig>


More information about the Spice-devel mailing list