qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] qom: add style guide


From: Michael S. Tsirkin
Subject: Re: [Qemu-devel] [PATCH] qom: add style guide
Date: Mon, 13 Aug 2012 22:55:29 +0300

On Mon, Aug 13, 2012 at 01:46:46PM -0500, Anthony Liguori wrote:
> +    typedef struct MyType MyType;
> +    
> +    struct MyType
> +    {

This seems to violate our style:should be

> +    struct MyType {



> +        Object parent_obj;
> +    
> +        /*< private >*/
> +        int foo;
> +    };
> +
> +When declaring the structure, a forward declaration should be used.  This is
> +useful for consistency sake as it is required when defining classes.
> +
> +The first element must be the parent type and should be named 'parent_obj' or
> +just 'parent'.

Why should it? Why not use a descriptive name that
makes it easier to see what the object actually is?

>  When working with QOM types, you should avoid ever accessing
> +this member directly instead relying on casting macros.
> +
> +Casting macros hide the inheritence hierarchy from the implementation.  This
> +makes it easier to refactor code over time by changing the hierarchy without
> +changing the code in many places.

This seems like a weak motivation. Why do you expect to refactor
hierarchy all the time?  The cost is replacing compile time checks with
runtime ones.

So refactoring is easier to make but harder to make correct.
Sounds like a bad tradeoff.

-- 
MST



reply via email to

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