[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kdevelop-devel
Subject:    Re: Someone mentioned accessor methods?
From:       Sascha Herrmann <starfox899 () web ! de>
Date:       2004-03-09 21:15:54
Message-ID: 404E340A.3000809 () web ! de
[Download RAW message or body]

Steven T. Hatton wrote:
> Also, C++ers tend to simply use the name of the member field as the name of 
> the retrieval (getter) method.  Agreed? 
> 
> What about passing a reference verses passing a value; to the mutator 
> (setter)?; as the return value?  
> 
> What about constness? 
> 
> Does someone have a paradigm for this they would like to share?

Hi,
i wont claim to set up a paradigm but in my eyes that should look like:

class test {
public:
     test();
     ~test();
     // get...
     const double& getSize() const;
     // set... (for "big" structures or whenever copying takes to long)
     void setSize(const double& newValue);
     // maybe better for standard types
     void setSize(const double newValue);
protected:
     double m_Size;
};

setters should be void because modern error handling should be done with 
exceptions (that`s what i think!). To improve things further we should 
create a template for get/setters so anybody can choose his favorite style.

bye sascha

PS: i am away untill sunday, so do not expect any answers from me next 
days ;-)

_______________________________________________
Kdevelop-devel mailing list
Kdevelop-devel@barney.cs.uni-potsdam.de
http://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic