[OT][接口设计]接口中数据粒度对于接口的影响

28 views
Skip to first unread message

Marmot

unread,
Jun 3, 2012, 12:39:02 AM6/3/12
to pon...@googlegroups.com
开个帖子,想专门讨论一下接口设计中数据粒度对于接口设计的影响.

比如     FooProperty A { int  a;  int b;  };

那么在接口中对于property  A 的 accessor , 以下两种设计:

Solution A :
            class  A { 
                    int  GetProperty( FooProperty& foo_property );
                    int  SetProperty( const FooProperty& foo_property );
                    };

Solution  B :
           class B {
                  int GetPropertyI( FooPropertyI*& foo_property_i );
           };

          class FooPropertyI {
                  int GetA();
                  void SetA( int a );
                  int GetB();
                  void SetB( int b );
          };

   讨论角度 :
    1.  分布式系统接口
    2.  进程内接口
 

qiaojie

unread,
Jun 3, 2012, 3:07:11 AM6/3/12
to pon...@googlegroups.com
肯定是A好了,B方案完全是在自找麻烦。


2012/6/3 Marmot <realw...@gmail.com>

huan yi

unread,
Jun 3, 2012, 8:29:56 PM6/3/12
to pon...@googlegroups.com
接口本来就是一个管道
上下游要什么,就提供什么接口,这样后续改造和出问题的几率会相对少些
--
Huan Yi
Q Q:173830574
focus:BSS/BOSS,billing,运营支撑
now: Asiainfo-Linkage
prev: HUST
 

pi1ot

unread,
Jun 3, 2012, 10:02:43 PM6/3/12
to pon...@googlegroups.com
如果有得选的话,更碎的那个吧,纯感觉。
Reply all
Reply to author
Forward
0 new messages