boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - class impl
相关主题
vector在constructor里初始化
请教C++11的rvalue ref
问个问题,关于隐藏实现细节, C plusplus
What does the default constructor do?
Java里面能 extends Scala object的abstract inner class吗?
Nested classes inside one class (C++)
C++ interview programming exercise
monad抽象程度有点高
两道Java面试问题
关于Java一个小程序的结果
相关话题的讨论汇总
话题: ifoo话题: foo话题: class话题: impl话题: foo1
进入Programming版参与讨论
1 (共1页)
d****p
发帖数: 685
1
I recently got confused about one thing.
Previously I have class design as:
class IFoo { ... } // abstract class
class Foo1 : public IFoo { ... }
class Foo2 : public IFoo { ... }
Recently all the code was modified by a colleague as:
class IFoo { ... }
class Foo1 { Impl *pImpl ... }
class Foo1::Impl { ... }
In short, the implementation was moved from Foo to Foo::impl, which
is an internal class.
What's the benefit of doing so? To me this is not nice since Foo is
suppose to be implementat
t****t
发帖数: 6806
2
usually pimpl idiom is to hide the implementation details and break the
compile-time dependency.
but i guess you already know that.

【在 d****p 的大作中提到】
: I recently got confused about one thing.
: Previously I have class design as:
: class IFoo { ... } // abstract class
: class Foo1 : public IFoo { ... }
: class Foo2 : public IFoo { ... }
: Recently all the code was modified by a colleague as:
: class IFoo { ... }
: class Foo1 { Impl *pImpl ... }
: class Foo1::Impl { ... }
: In short, the implementation was moved from Foo to Foo::impl, which

d****p
发帖数: 685
3
Thanks - but that's why I am confused.
If its purpose is to decouple any units include-ing Foo.h and Foo's
actual implementation, the situation already justifies promoting Foo into
a higher level as abstract class such as IFoo.
So basically it is
abstract(IFoo) - semi abstract (Foo) - solid (Foo::Impl)
vs
abstract (IFoo) - abstract (IFoo) - solid (Foo).
Maybe I am missing sth but I deem the second concept is cleaner.
Hmm seems the 1st approach does have merit - its instan

【在 t****t 的大作中提到】
: usually pimpl idiom is to hide the implementation details and break the
: compile-time dependency.
: but i guess you already know that.

1 (共1页)
进入Programming版参与讨论
相关主题
关于Java一个小程序的结果
问一下这个cast在java里是怎么work的
A C++ inheritance question!
如何在C里面call C++的routine呢
为什么foo1可以而foo2不行?
现在流行microframework
设计一种c++语言的新特性
How does YAHOO calculate RSI? (转载)
请教template和factory有啥区别?
map是用什么data structure来implement的?
相关话题的讨论汇总
话题: ifoo话题: foo话题: class话题: impl话题: foo1