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 Þor! 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 34 4572
* "Steven T. Hatton" <su******@setid ava.kushan.aa> schriebt: 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.)
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" <su******@setid ava.kushan.aa> schriebt: 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.)
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. Steinbach wrote: * "Steven T. Hatton" <su******@setid ava.kushan.aa> schriebt: 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.
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.
*(Sutter does serve the Dark Lord, but that's a different story. Lippman, too has passed into darkness.)
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.
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
Alf P. Steinbach wrote: * "Steven T. Hatton" <su******@setid ava.kushan.aa> schriebt: 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.
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.
*(Sutter does serve the Dark Lord, but that's a different story. Lippman, too has passed into darkness.)
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.
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
"Steven T. Hatton" <su******@setid ava.kushan.aa> wrote in message
news:ea******** ************@sp eakeasy.net... 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 Þor! 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.
Well come on then - bless us all with your insight.
I don't see how there can logically be a "better more 'conventional' way"
since this IS
the conventional way.
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" <su******@setid ava.kushan.aa> wrote in message
news:ea******** ************@sp eakeasy.net... 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 Þor! 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.
Well come on then - bless us all with your insight.
I don't see how there can logically be a "better more 'conventional' way"
since this IS
the conventional way.
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
Nick Hounsome wrote: "Steven T. Hatton" <su******@setid ava.kushan.aa> wrote in message news:ea******** ************@sp eakeasy.net... 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 Þor! 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.
Well come on then - bless us all with your insight. I don't see how there can logically be a "better more 'conventional' way" since this IS the conventional way.
You may notice I have '/feel/' emphasized, and ''conventional' ' in single
quotes. The intent of the former was to stress that I do not have
a /reasoned/ alternative. The intent of the latter was that I didn't
really mean the CFI (Compiler Firewall Idiom) is unconventional.
What do you see as the motive for it? Do you use it ubiquitously? I'll have
to start examining the headers in some of the programs I have the source
for to see if and how it is used there.
--
STH
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org
Nick Hounsome wrote: "Steven T. Hatton" <su******@setid ava.kushan.aa> wrote in message news:ea******** ************@sp eakeasy.net... 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 Þor! 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.
Well come on then - bless us all with your insight. I don't see how there can logically be a "better more 'conventional' way" since this IS the conventional way.
You may notice I have '/feel/' emphasized, and ''conventional' ' in single
quotes. The intent of the former was to stress that I do not have
a /reasoned/ alternative. The intent of the latter was that I didn't
really mean the CFI (Compiler Firewall Idiom) is unconventional.
What do you see as the motive for it? Do you use it ubiquitously? I'll have
to start examining the headers in some of the programs I have the source
for to see if and how it is used there.
--
STH
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org
Steven T. Hatton wrote: 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 Þor! 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.*
"Pimpl" is an idiom that one refactors into existing code to compile faster.
Refactors change design while leaving behavior the same. The Pimpl refactor
leaves logical design the same while tweaking physical design, so
translation units needn't see the details of other classes. That prevents
excessive recompiles when you change a highly reused class.
But Pimpl is for emergencies, after a design is committed. C++ was designed
to permit compilation firewalls based on abstract types; Pimpl abstracts a
concrete type.
Robert C. Martin's "Dependency Inversion Principle" describes this design
goal. http://www.objectmentor.com/resources/articles/dip.pdf
It implies that only classes with a few pure-virtual methods should be
widely re-used. This is both a valid design technique and a system that, in
C++, prevents runaway re-compiles.
--
Phlip http://www.xpsd.org/cgi-bin/wiki?Tes...UserInterfaces This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steven T. Hatton |
last post by:
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 Þor! 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...
|
by: Debajit Adhikary |
last post by:
I'm still pretty new to design patterns... I was wondering, is there
any difference between the Bridge Pattern and Herb Sutter's Pimpl
Idiom?
Both delegate responsibility to an implementation and thus allow a
clear and flexible separation of interface and implementation such that
the implementation can be changed freely.
|
by: Mikhail N. Kupchik |
last post by:
Hi All.
I have a question regarding Herb Sutter's idiom of implementation of
operator= via nonthrowing swap() member function, to guarantee strict
exception safety.
The idea of the idiom is shown by the example:
-- code fragment 1 ----------------------------------------------------
class MyClass
|
by: swengtoo |
last post by:
In his book "More Effective C++", Scott Meyer suggests in "Item 4" to
"Avoid gratuitous default constructors".
To summarize his claims against default constructors for "the right
classes" he states that:
================== START QUOTE =============
"A default constructor is the C++ way of saying you can get something
for nothing. Constructors initialize objects, so default constructors
initialize objects without any information from...
|
by: Joel Hedlund |
last post by:
Hi!
I need some input on my use of metaclasses since I'm not sure I'm using them in
a pythonic and graceful manner. I'm very grateful for any tips, pointers and
RTFMs I can get from you guys.
Below, you'll find some background info and an executable code example.
In the code example I have two ways of doing the same thing. The problem is
that the "Neat" version doesn't work, and the "Ugly" version that works gives
| |
by: Noah Roberts |
last post by:
Item #1 in the More Exceptional C++ book uses the following construct:
fstream in;
....
process( in.is_open() ? in : cin,...);
Where process has been shown as having various multiple different
|
by: Gennaro Prota |
last post by:
Hi,
after several "tweaks" I think I've finally found a file layout which
I like for my code (in terms of where the copyright line and the
license reference go, where the vim modeline etc.). For included
files, I've stuck so far to the suggestion in C++ Coding Standards
which says:
Don't try to be clever: Don't put any code or comments before
and after the guarded portion, and stick to the standard form
|
by: WaterWalk |
last post by:
I've just read an article "Building Robust System" by Gerald Jay
Sussman. The article is here:
http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf
In it there is a footprint which says:
"Indeed, one often hears arguments against building exibility into an
engineered sys-
tem. For example, in the philosophy of the computer language Python it
is claimed:
\There should be one|and preferably only one|obvious...
|
by: benhoyt |
last post by:
Hi guys,
I've been using Python for some time now, and am very impressed with
its lack of red tape and its clean syntax -- both probably due to the
BDFL's ability to know when to say "no".
Most of the things that "got me" initially have been addressed in
recent versions of Python, or are being addressed in Python 3000. But
it looks like the double underscores are staying as is. This is
probably a good thing unless there are better...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |