Sutter的粉刺:好,坏,还是丑? [英] Sutter's Pimples: Good, Bad, or Ugly?

查看:66
本文介绍了Sutter的粉刺:好,坏,还是丑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Pete Vilder几天前提到了这一点。这是Compiler-Firewall

Idiom或者疙瘩。它类似于一些Java设计中采用的方法。

AAMOF,当我在Java中看到它时,我的第一反应是哦,Tor!这是'b $ b freakin''标题一遍又一遍! 


我对这种方法的最大担忧是它似乎太过分了

很复杂。我感觉/似乎有一种更好的''传统''方式来处理界面和实现的分离。 OTOH,这对我来说很明显,那些提倡它的人并不傻。*


这里是讨论: http://www.gotw.ca/publications/mill05.htm


你用它做什么?


*(萨特确实为黑魔王服务,但这是另一回事.Lippman,

也已经进入黑暗。)


-

p-> m ==(* p).m = = p [0] .m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org

Pete Vilder mentioned this a few days back. This is the "Compiler-Firewall
Idiom", or pimple. It''s similar to an approach taken in some Java designs.
AAMOF, when I saw it in Java, my first reaction was "Oh by Tor! It''s
freakin'' headers all over again!"

My greatest misgiving about the approach is that it seems overly
complicated. I /feel/ as if there is a better more ''conventional'' way of
dealing with the separation of interface and implementation. OTOH, it''s
clear to me that the people who have advocated it are not stupid.*

Here''s the discussion: http://www.gotw.ca/publications/mill05.htm

What do you make of it?

*(Sutter does serve the Dark Lord, but that''s a different story. Lippman,
too has passed into darkness.)

--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org

推荐答案

*" Steven T. Hatton" <苏****** @ setidava.kushan.aa> schriebt:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

你是怎么做到的?


太懒也太看了讨论 - 我之前就在这里和期间

吧。


pimpl的要点不是将类接口和实现分开,因为你好像想的那样。


它是删除头文件依赖。例如,用于

流行图像库的C头文件可能使用单词class。一个非常流行的操作系统的头文件可能会使用各种各样的宏和讨厌的东西。


完成相同基本目的的pimpl的替代方案,但结果是

a限制,是在头文件中只声明一个抽象类和一个工厂

函数。


限制是实施继承有效地被禁用; b $ b禁用;客户端代码无法访问实际的

派生的声明,工厂函数具有返回类型的具体类。

*(Sutter确实为黑魔王服务,但那是一个不同的故事.Lippman,
也已经陷入了黑暗。)

What do you make of it?
Too lazy too look up the discussion -- I was here before that and during
it.

The gist of pimpl is not to separate class interface and implementation, as
you seem to think.

It is to remove a header file dependency. For example, a C header file for a
popular imaging library might use the word "class". And a header file for a
very popular operating system might use all sorts of macros and nasty stuff.

An alternative to pimpl that accomplishes the same basic purpose, but with
a limitation as result, is to declare only an abstract class and a factory
function in the header file.

The limitation is that implementation inheritance is then effectively
disabled; the client code has no access to the declaration of the actual
derived, concrete class that the factory function has as return type.
*(Sutter does serve the Dark Lord, but that''s a different story. Lippman,
too has passed into darkness.)




您是否愿意像以前一样盲目地绊倒微软?在这两个版本的帮助下,最新版本的Visual C ++是符合标准的最符合标准的编译器之一,至少在忽视像
$这样的微不足道的东西时b $ b默认情况下能够使用标准的''main'',例外和RTTI。

以前它是最不合规的地方之一,即使是微不足道的

符合标准的代码无法编译,在一个无证的特设公司标准的la-la土地上摧毁了大部分C ++

从业者。


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么顶级发布这么糟糕的事情?

A:热门发布。

问:usenet和电子邮件中最烦人的事情是什么?



Would you rather have Microsoft stumbling blindly on as before? With the help
of those two the latest version of Visual C++ is one of the most
standard-conforming compilers, at least when disregarding trivial stuff like
being able to use a standard ''main'', exceptions and RTTI by default.
Previously it was one of the most non-compliant where even trivial
standard-conforming code would not compile, stranding a large fraction of C++
practitioners in the la-la land of an undocumented ad-hoc company standard.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


*" ; Steven T. Hatton" <苏****** @ setidava.kushan.aa> schriebt:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

你是怎么做到的?


太懒也太看了讨论 - 我之前就在这里和期间

吧。


pimpl的要点不是将类接口和实现分开,因为你好像想的那样。


它是删除头文件依赖。例如,用于

流行图像库的C头文件可能使用单词class。一个非常流行的操作系统的头文件可能会使用各种各样的宏和讨厌的东西。


完成相同基本目的的pimpl的替代方案,但结果是

a限制,是在头文件中只声明一个抽象类和一个工厂

函数。


限制是实施继承有效地被禁用; b $ b禁用;客户端代码无法访问实际的

派生的声明,工厂函数具有返回类型的具体类。

*(Sutter确实为黑魔王服务,但那是一个不同的故事.Lippman,
也已经陷入了黑暗。)

What do you make of it?
Too lazy too look up the discussion -- I was here before that and during
it.

The gist of pimpl is not to separate class interface and implementation, as
you seem to think.

It is to remove a header file dependency. For example, a C header file for a
popular imaging library might use the word "class". And a header file for a
very popular operating system might use all sorts of macros and nasty stuff.

An alternative to pimpl that accomplishes the same basic purpose, but with
a limitation as result, is to declare only an abstract class and a factory
function in the header file.

The limitation is that implementation inheritance is then effectively
disabled; the client code has no access to the declaration of the actual
derived, concrete class that the factory function has as return type.
*(Sutter does serve the Dark Lord, but that''s a different story. Lippman,
too has passed into darkness.)




您是否愿意像以前一样盲目地绊倒微软?在这两个版本的帮助下,最新版本的Visual C ++是符合标准的最符合标准的编译器之一,至少在忽视像
$这样的微不足道的东西时b $ b默认情况下能够使用标准的''main'',例外和RTTI。

以前它是最不合规的地方之一,即使是微不足道的

符合标准的代码无法编译,在一个无证的特设公司标准的la-la土地上摧毁了大部分C ++

从业者。


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么顶级发布这么糟糕的事情?

A:热门发布。

问:usenet和电子邮件中最烦人的事情是什么?



Would you rather have Microsoft stumbling blindly on as before? With the help
of those two the latest version of Visual C++ is one of the most
standard-conforming compilers, at least when disregarding trivial stuff like
being able to use a standard ''main'', exceptions and RTTI by default.
Previously it was one of the most non-compliant where even trivial
standard-conforming code would not compile, stranding a large fraction of C++
practitioners in the la-la land of an undocumented ad-hoc company standard.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


Alf P斯坦巴赫写道:
Alf P. Steinbach wrote:
*" Steven T. Hatton" <苏****** @ setidava.kushan.aa> schriebt:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

你是怎么做到的?
太懒了也在讨论 - 我之前就在这里和
期间。

pimpl的要点不是将类接口和实现分开,就像你想象的那样。

What do you make of it?
Too lazy too look up the discussion -- I was here before that and during
it.

The gist of pimpl is not to separate class interface and implementation,
as you seem to think.




这可能是一个问题语义。我看到这个的方式类似于在Java中实现org.w3c.dom语言绑定的方式。有一组

的API抽象类和接口,客户端程序员

写入。然后有一个实现,可以在不更改客户端代码的情况下替换。对于您使用工厂的示例,这个特定示例实际上可能更接近

。尽管如此,动机是

相同。

它是删除头文件依赖项。例如,流行的成像库的C头文件可能使用单词class。


Imagemagick?

一个非常流行的操作系统的头文件可能会使用各种各样的宏和令人讨厌的东西。


我无法想象。 ;-)嘿,这是开源的优势。我可以自由地讨论设计错误,如果人们同意,最终将会解决这个问题。

pimpl的替代方案可以完成相同的基本目的,但结果是限制,只是在头文件中声明一个抽象类和一个工厂
函数。

限制是实现继承是然后有效地禁用;客户端代码无权访问工厂函数作为返回类型的实际派生的具体类的声明。


我必须考虑这个。我不确定用pimpl扩展

a级的容易程度。



This may be a question of semantics. The way I see this is similar to the
way the org.w3c.dom language binding is implemented in Java. There is a
set of API abstract classes and interfaces which the client programmer
writes to. Then there is an implementation which can be replaced without
changing the client code. This particular example may actually be closer
to your example of using a factory. Nonetheless, the motivation is the
same.
It is to remove a header file dependency. For example, a C header file
for a popular imaging library might use the word "class".
Imagemagick?
And a header file for
a very popular operating system might use all sorts of macros and nasty
stuff.
I can''t imagine. ;-) Hey, that''s an advantage of Open Source. I can freely
discuss the design faults, and if people agree, it will eventually be
addressed.
An alternative to pimpl that accomplishes the same basic purpose, but with
a limitation as result, is to declare only an abstract class and a factory
function in the header file.

The limitation is that implementation inheritance is then effectively
disabled; the client code has no access to the declaration of the actual
derived, concrete class that the factory function has as return type.
I''ll have to think about this one. I''m not sure about the ease of extending
a class with a pimpl.

*(萨特确实为黑魔王服务,但是这是一个不同的故事。
Lippman也陷入了黑暗之中。)
*(Sutter does serve the Dark Lord, but that''s a different story.
Lippman, too has passed into darkness.)



你宁愿让微软盲目地磕磕绊绊吗?在这两个版本的帮助下,最新版本的Visual C ++是最符合标准的编译器之一,至少在忽视一些琐碎的东西时,比如能够使用标准的'main默认情况下,例外和RTTI。
以前它是最不合规的地方之一,甚至琐碎的标准符合代码都无法编译,使大部分的C ++从业者陷入困境一个无证件的特设公司的la-la土地
标准。



Would you rather have Microsoft stumbling blindly on as before? With the
help of those two the latest version of Visual C++ is one of the most
standard-conforming compilers, at least when disregarding trivial stuff
like being able to use a standard ''main'', exceptions and RTTI by default.
Previously it was one of the most non-compliant where even trivial
standard-conforming code would not compile, stranding a large fraction of
C++ practitioners in the la-la land of an undocumented ad-hoc company
standard.




所以,你建议Sutter和Lippman从黑暗中引领他们
进入光明?


-

p-> m ==(* p).m == p [0] .m
http://www.kdevelop.org
< a rel =nofollowhref =http://www.suse.comtarget =_ blank> http://www.suse.com
http://www.mozilla.org



So, you are suggesting Sutter and Lippman are leading them from darkness
into the Light?

--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org


这篇关于Sutter的粉刺:好,坏,还是丑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆