Boost logo

Boost :

From: Michael D. Crawford (crawford_at_[hidden])
Date: 2005-11-02 16:21:37


Friends,

I'd like your expert opinions on a C++ article I'm writing. I plan to
submit it in a few hours to the community website Kuro5hin
(http://www.kuro5hin.org/). I will leave it in "edit mode" until
tomorrow, so I'll still have time to revise it to reflect your comments.

 From my introduction:

    "When I talk to those guys about how to write better code I have the
    sense that their experience of me is like going to church."

    "Many people go to church. How many are without sin?"

    "But I didn't learn to preach because I studied at the seminary. It
    is because I was a derelict on skid row until I was saved by..."

         "... smart pointers and automated testing."

Sermon at the Soup Kitchen
On C++ Software Quality and Institutional Resistance to Change
http://www.goingware.com/tips/smart-pointers-and-automated-testing/

My questions:

0. Am I correct in what I say about the various Boost smart pointers? I
say shared_ptr isn't thread safe. Am I right? If so, does
Boost::Thread offer a way to make thread-safe reference counted smart
pointers? If so, please point out any documentation to me so I can link
to it from my piece.

1. I was hired specifically to revamp the company's software
development methodology so they achieve high reliability, as even a
single incident of failure of their Computer Aided Design product could
cost end-users as much as a million dollars if the products designed by
it failed to work as designed when manufactured. But when the chips
were down, "Yoyodyne" founder "Jack" ordered everyone, me included, to
cut corners so we could implement features faster. This led to my
ultimatum quoted in the article. I'm now looking for a new job.

My question for you is, given that Jack was not a programmer, and didn't
have the first clue about how to achieve software quality (nor did the
rest of the staff), how could I have overcome the company's resistance
to change in such a way that it wouldn't have come to an ultimatum?

2. I have a few links to smart pointer and automated testing pages
early in the article, but not many. Can you suggest others? I'm
especially interested to hear about other test frameworks, not just for
C++ but for *any* language, so that people who don't use C++ still have
something to gain by reading my piece. How about frameworks for other
kinds of testing than unit testing, like acceptance or integration testing?

3. Can you pick any nits with my assertions about C++ or the various
smart pointers? Do you agree with me that the following is a case where
auto_ptr is the best choice? Can you think of others?

http://www.goingware.com/tips/smart-pointers-and-automated-testing/#when-to-use-auto_ptr

4. I say early on that neither auto_ptr nor the Boost smart pointers
provide all the different kinds of smart pointers one would want. What
other kinds can you think of? How would they be implemented? I already
have a couple completely implemented, and keep thinking of more, but I'd
like ideas for others to discuss in my next installment. I won't tell
you my answers yet because I want to stimulate discussion.

I'll be placing all my smart pointers under the Boost license and
posting a tarball on my website. You're welcome to include them in
Boost, but if you don't want to, I'll host them at Sourceforge.

5. I've already been over my article several times looking for grammar
and spelling errors, but if you can still find any, please let me know.

6. If you were a sinner before you came to my soup kitchen's service,
have I saved your soul? If not, how could I have made my case more
effectively? Was your free, hot supper satisfying? Would you come back
for more?

My article is going to appear in two or three installments at Kuro5hin.
  The next one, yet to be written, will cover automated testing. I'm
also going to cover exception safety, which I feel I have finally come
to understand. Depending on how long the second installment is,
exception safety might appear there, or in a third installment. I'll
discuss the connection between RAII, smart pointers and exception safety.

As I deliver each sermon, I'll add it at the link above. Look for them
in the table of contents, quoted below.

Part I

     * How I Was Saved
           o Smart Pointers
           o Automated Testing
     * Ultimatum
     * auto_ptr and Its Alternatives
           o auto_ptr Doesn't Work for Arrays
           o Take My Memory. Please!
           o The Simple Solution
           o Standard Template Library-Compatible Smart Pointers
           o That's Great! Is It Thread-Safe Too?
           o But Arrays? What About the Arrays?
           o So is auto_ptr Completely Useless?
           o Without Further Ado
     * The Right Tool for the Job

Part II

     * The Path of Righteousness

Part III

     * The Holy Grail

Thanks for your help!

-- 
Michael D. Crawford
GoingWare Inc. - Expert Software Development and Consulting
http://www.goingware.com/
crawford_at_[hidden]
    Tilting at Windmills for a Better Tomorrow.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk