[Y-devel] Y-Protocol proposal, again :-)
Kris Van Hees aedil-y-devel at alchar.org
Tue Apr 13 16:23:41 BST 2004
The one major disadvantages to using values for events/messages is that you
make the assumption that both server and client will indeed *NEVER* renumber
anything. That is all fine, if you work with definition files that associate
the values with meanings *AND* put the rule in place that no value will ever
be reused. That usually results in a very messy file that needs a text editor
search if you look for the code for a certain message because, well, you cannot
depend on any order. No big deal, though. Until someone decides that cleaning
up that file really should be done (but it won't be possible), or when someone
feels that (either for easthetic reasons, or for actual design reasons) a block
of values should be set aside for a certain module, to be used at will. Which
means you will lose in the end, because assigning actual semantic meaning to
arbitrary values is *BAD*.
I'm not saying that going with pure values is a bad idea, but we need to have
a total commitment that values will be assigned from either 0 or UINTMAX, with
no gaps, and whenever a value is no longer needed, the value is *LOST*, so
that it is guaranteed that values will never, ever be reused. Even if it seems
a good idea, or what e.g. with a major release, clients and servers should be
back in sync, and thus renumbering seems possible. Just never do it :)
Kris
On Tue, Apr 13, 2004 at 11:33:21AM +0200, Maurice van der Pot wrote:
> While we're on the subject of protocol changes,
> can anyone tell me why you would want text strings
> to identify types of events/messages instead
> of something like an unsigned 32-bit value?
>
> So far I have heard the argument that it would
> prevent recompilation of sources each time a new
> message type is added. Although this might be true,
> I don't think having to do some recompilation of
> only a small part of the total source and only
> when message types change, should be a reason to
> opt for something that has a negative impact on
> performance. Of course I know that the impact is
> minimal, but you don't say "let's take this thing
> that's slightly slower, because it is only slightly
> slower."
>
> Based on this, I'd say use fixed size, fast and easy
> to convert fields like an unsigned 32-bit integer.
>
> Just one remark about use of 32-bit values: they don't
> have to be human readable and you don't have to do
> math with it, so don't reorder them when you receive
> them if they don't match your architecture's endianness.
> It's faster and just as easy to have a macro swap
> the bytes in the header file during compilation.
> All you are allowed to do with the values is comparing
> equality and writing them to messages anyway.
More information about the Y-devel mailing list
2026 © www.Y-Windows.Org - All Rights Reserved