style
Jarrett Billingsley
kb3ctd2 at yahoo.com
Mon May 22 09:06:42 PDT 2006
<sclytrack at pi.be> wrote in message news:e4s007$2ejs$1 at digitaldaemon.com...
> I was wondering about the style to be used in D, especially related to
> private
> and protected members.
>
> Java has get and set methods.
>
> class Window {
> private:
> char [] caption;
> public:
> char [] getCaption() {}
> }
>
> Is above good D-style?
I make it a _personal crusade_ to do away with the words "get" and "set" in
method names. I always just use the name of the property I'm setting or
getting; that way, it can be used as a D property as well.
obj.caption = "hi"; // set
writefln(obj.caption); // get
> class Window
> {
> private:
>
> //What name should this be, of course one can choose because its private.
> //Borland goes with FCaption;
>
> char [] mcaption;
I use "mCaption." In fact, I've made it such a habit to prefix all member
variables with "m," that if I read other peoples' code where they don't have
any kind of distinguishing characteristic for member variables, it's _very_
difficult for me to read!
More information about the Digitalmars-d
mailing list