Mailing List archive

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

[linux-dvb] Re: NEWSTRUCT: type names



Hi Klaus,

Klaus Schmidinger wrote:
> I'm just in the process of implementing all parameters necessary
> for supporting DVB-C and DVB-T into VDR. In doing so I want to give
> my cChannel class a member function that returns, for instance, the
> "hierarchy" value, as in
> 
>   class cChannel {
>     ...
>   private:
>     Hierarchy hierarchy;
>   public:
>     Hierarchy Hierarchy(void) { return hierarchy; }
>     ...
>     };
> 
> The name of the function shall be Hierarchy(), but since the return
> value will have to be of type Hierarchy (as defined in the driver's
> frontend.h), I'm facing a naming problem here.

why don't you call your function GetHierarchy() or put the 
LinuxDVB-header in an extra namespace before you include the file?


> 
> Wouldn't it be better to use some naming convention for typedefs/enums
> in the driver? Something like
> 
>   typedef enum {
>         HIERARCHY_NONE,
>         HIERARCHY_1,
>         HIERARCHY_2,
>         HIERARCHY_4,
>         HIERARCHY_AUTO
>   } eHierarchy;

no, I don't like the hungarian notation and it's not usual in kernel 
definitions. Modern coding style books even discourage from using this 
notation because of it's useless redundancy. The compiler can check 
correct type usage.

For some pamphlets about this style check out
http://www.quinion.com/words/articles/hungary.htm
http://ootips.org/hungarian-notation.html


> Note the 'e' in front of the type name, marking it as an 'enum'.
> Then my class could be
> 
>   class cChannel {
>     ...
>     eHierarchy Hierarchy(void) { return hierarchy; }
>     ...
>     };
> 
> The same applies to many other enums in the driver.
> For the moment I'll make my functions return 'int' and typecast
> the result when calling them...

This will disable typechecking by the compiler, don't do it unless you 
really have to do so.

Holger



-- 
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.



Home | Main Index | Thread Index