so, providing semantic thing is the first step that we should consider. providing syntax is a paradox at here. we can do a compromise about syntax if we can't do the first step. just like dealing with data with batch in a form of struct.
but i want to ask what is the difference with the original?
in my opinion, the calling of set and get method have been doubled, the class that originally has the datas have to use those get and set too.
to magicblue(小飞侠), oopig(面向对象的猪)
举个例子:
class A
{
private:
int i;
public:
int get_i();
int set_i(int j);
};
上面的这个类,专门为i设计读写的接口,这样实在是没有必要。须知接口的目的之一是为了数据验证和防止错误。但是如果以这样的代价来达到验证防错的效果,在整个设计上是得不偿失。