M
mscava
Recently I've came to a small problem... I've read few coding
guidelines, to improve and standardize my style. Most of them advised
me to use function prefixes such as Get, Set, Compute etc..
I understand that avoiding Set prefix might be very confusing and I
feel that one is right.
But what about others?
class Rectangle
{
public:
inline int ComputeArea() const { return w_ * h_; }
inline int GetX() const { return x_; }
inline int GetY() const { return y_; }
inline int GetWidth() const { return w_; }
inline int GetHeight() const { return h_; }
private:
int x_, y_;
int w_, h_;
};
I feel like it's just too verbose... what about:
class Rectangle
{
public:
inline int Area() const { return w_ * h_; }
inline int X() const { return x_; }
inline int Y() const { return y_; }
inline int Width() const { return w_; }
inline int Height() const { return h_; }
private:
int x_, y_;
int w_, h_;
};
Can anyone advise me one of these? Or at least show me some pros &
cons?
Thanks
guidelines, to improve and standardize my style. Most of them advised
me to use function prefixes such as Get, Set, Compute etc..
I understand that avoiding Set prefix might be very confusing and I
feel that one is right.
But what about others?
class Rectangle
{
public:
inline int ComputeArea() const { return w_ * h_; }
inline int GetX() const { return x_; }
inline int GetY() const { return y_; }
inline int GetWidth() const { return w_; }
inline int GetHeight() const { return h_; }
private:
int x_, y_;
int w_, h_;
};
I feel like it's just too verbose... what about:
class Rectangle
{
public:
inline int Area() const { return w_ * h_; }
inline int X() const { return x_; }
inline int Y() const { return y_; }
inline int Width() const { return w_; }
inline int Height() const { return h_; }
private:
int x_, y_;
int w_, h_;
};
Can anyone advise me one of these? Or at least show me some pros &
cons?
Thanks