Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] Re: NEWSTRUCT: type names
Holger Waechtler wrote:
>
> 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?
The name GetHierarchy() IMHO implies that this would be a process that
causes some bigger action (like going somewhere and actually getting it).
Since it is just a function that allows access to the otherwise private
data member 'hierarchy' I'd like to simply name it Hirarchy().
Nevermind, I've used typecasts and that works fine for me.
> > 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.
I don't like the HN either, but with enums I've come to find it useful
to be able to simply come up with a name by just preceeding whatever this
is about with 'e'. Note that HN usually is about marking *variables* with the
type - that's not what I'm suggesting. I was talking about a *type* name.
> 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.
I know, but since this only happens in one specific place, and chances are very
little that the type definition of these names will change, I can live with that.
Klaus
--
_______________________________________________________________
Klaus Schmidinger Phone: +49-8635-6989-10
CadSoft Computer GmbH Fax: +49-8635-6989-40
Hofmark 2 Email: kls@cadsoft.de
D-84568 Pleiskirchen, Germany URL: www.cadsoft.de
_______________________________________________________________
--
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.
Home |
Main Index |
Thread Index