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
Jul 22 '05
34 4580
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
"Steven T. Hatton" <su******@setid ava.kushan.aa> 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.*
Here's the discussion: http://www.gotw.ca/publications/mill05.htm
What do you make of it?
The only time I have used the pimpl idiom is when I need compile time
polymorphism. For example when I have a class that is implemented
completely differently for two different architectures but have the same
interface. I will have one header file, and two (or three) source files
for the class. (Foo.h, FooCommon.cpp, FooMac.cpp, FooWindows.cpp for
example) This allows all programs to use the same header even though the
two architectures use completely different internal variables and
implementations .
"Steven T. Hatton" <su******@setid ava.kushan.aa> 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.*
Here's the discussion: http://www.gotw.ca/publications/mill05.htm
What do you make of it?
The only time I have used the pimpl idiom is when I need compile time
polymorphism. For example when I have a class that is implemented
completely differently for two different architectures but have the same
interface. I will have one header file, and two (or three) source files
for the class. (Foo.h, FooCommon.cpp, FooMac.cpp, FooWindows.cpp for
example) This allows all programs to use the same header even though the
two architectures use completely different internal variables and
implementations .
"Steven T. Hatton" <su******@setid ava.kushan.aa> wrote in message
news:RY******** ************@sp eakeasy.net... 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.
2 motives: reduce compile time. reduce dependencies between programmers
/groups in large project
or between library and user.
I don't use it much lately because I'm only doing smallish stuff on my own.
On small projects the compiler does most of its work parsing all the
standard headers that you tend to need so the saving would be minimal
anyway.
I did recently have cause to use it when doing embedded work as it allowed a
different pimpl to be used when testing on the host without having to #ifdef
all the headers that only existed in the target.
I suppose that people would say that factory is the pattern for this but it
would have been overkill and
you still need a handle to factory generated object which is not unlike a
class and its pimpl.
I really don't think that there is a better way in C++.
"Steven T. Hatton" <su******@setid ava.kushan.aa> wrote in message
news:RY******** ************@sp eakeasy.net... 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.
2 motives: reduce compile time. reduce dependencies between programmers
/groups in large project
or between library and user.
I don't use it much lately because I'm only doing smallish stuff on my own.
On small projects the compiler does most of its work parsing all the
standard headers that you tend to need so the saving would be minimal
anyway.
I did recently have cause to use it when doing embedded work as it allowed a
different pimpl to be used when testing on the host without having to #ifdef
all the headers that only existed in the target.
I suppose that people would say that factory is the pattern for this but it
would have been overkill and
you still need a handle to factory generated object which is not unlike a
class and its pimpl.
I really don't think that there is a better way in C++.
* "Steven T. Hatton" <su******@setid ava.kushan.aa> schriebt: Phlip wrote:
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.
That was the kind of answer I was looking for.
I'm hereby giving up on you. You chose the only response that was all dress
and no actual content. That fancy dressed "girl" is a boy, Steven.
--
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: Phlip wrote:
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.
That was the kind of answer I was looking for.
I'm hereby giving up on you. You chose the only response that was all dress
and no actual content. That fancy dressed "girl" is a boy, Steven.
--
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: Phlip wrote:
> 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.
That was the kind of answer I was looking for.
I'm hereby giving up on you. You chose the only response that was all dress and no actual content. That fancy dressed "girl" is a boy, Steven.
I didn't say it was the correct answer. All I intended was that it seems to
suggest there are better ways to address some or most circumstances in
which the CFI would be used. I have to say the concern about compile time
makes me a bit uneasy. If anything, I would say the long compile times are
a symptom not the disease.
So, I was looking at Martin's book, but I bought these instead: http://www.josuttis.com/libbook/index.html http://www.oreilly.com/catalog/cpluspluspr/
Have I gained any redemption?
--
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 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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: 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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| | |