digitalmars.D - style
- sclytrack pi.be (25/25) May 22 2006 I was wondering about the style to be used in D, especially related to p...
- Daniel Keep (22/58) May 22 2006 Personally, I use this:
- Lars Ivar Igesund (6/20) May 22 2006 I believe Mango do this quite extensively.
- Daniel Keep (6/24) May 22 2006 WELL. That settles it, then :)
- Jarrett Billingsley (10/27) May 22 2006 I make it a _personal crusade_ to do away with the words "get" and "set"...
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? Below you already need 2 or 3 names. Which names should they be? class Window { private: //What name should this be, of course one can choose because its private. //Borland goes with FCaption; char [] mcaption; public: char [] caption() {} void caption(char[] pcaption) { mcaption = pcaption; } } So give me the best D-style names. :-)
May 22 2006
sclytrack pi.be wrote: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?Yuck. By the way, that's just my *personal* opinion :)Below you already need 2 or 3 names. Which names should they be? class Window { private: //What name should this be, of course one can choose because its private. //Borland goes with FCaption; char [] mcaption; public: char [] caption() {} void caption(char[] pcaption) { mcaption = pcaption; } } So give me the best D-style names. :-)Personally, I use this: A question of my own: does anyone define the return type of the 'setter', and then return the value like this: I'm under the impression this is good because it allows you to chain assignment statements; but does anyone actually do this? -- Daniel -- v1sw5+8Yhw5ln4+5pr6OFma8u6+7Lw4Tm6+7l6+7D a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/
May 22 2006
Daniel Keep wrote:A question of my own: does anyone define the return type of the 'setter', and then return the value like this: I'm under the impression this is good because it allows you to chain assignment statements; but does anyone actually do this? -- DanielI believe Mango do this quite extensively. -- Lars Ivar Igesund blog at http://larsivi.net DSource & #D: larsivi
May 22 2006
Lars Ivar Igesund wrote:Daniel Keep wrote:WELL. That settles it, then :) -- Daniel -- v1sw5+8Yhw5ln4+5pr6OFma8u6+7Lw4Tm6+7l6+7D a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/A question of my own: does anyone define the return type of the 'setter', and then return the value like this: I'm under the impression this is good because it allows you to chain assignment statements; but does anyone actually do this? -- DanielI believe Mango do this quite extensively.
May 22 2006
<sclytrack pi.be> wrote in message news:e4s007$2ejs$1 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); // getclass 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!
May 22 2006