Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > RAII Design Patterns and Alternatives

Reply
Thread Tools

RAII Design Patterns and Alternatives

 
 
JohnQ
Guest
Posts: n/a
 
      03-10-2007
Scenario: A GUI program is developed such that the startup sequence is
controlled by the instantiation of a key object which instantiates other
objects etc. until it finally arrives at the point where it is waiting in
the message loop for messages to be put in its queue.

That is, unless something goes wrong during one of those object
instantiations in the program startup processing! Say somewhere in the
middle of all that startup processing, something does go wrong. Well, if the
objects were built with the RAII/exception architecture, the stack would
unwind back to the catch point. At which point, just maybe, an error would
be logged and the program would abort.

Or maybe, knowing that the OS is going to clean up resources for us when the
program aborts, maybe it is a lot simpler just to program the objects so
that they log and abort (sans exceptions) whenever they encounter error.

Whaddaya think?

John


 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      03-10-2007
JohnQ wrote:

> Or maybe, knowing that the OS is going to clean up resources for us when
> the program aborts, maybe it is a lot simpler just to program the objects
> so that they log and abort (sans exceptions) whenever they encounter
> error.
>
> Whaddaya think?


Write code ready to be refactored and upgraded. That means never rely on the
Memory Fairy today, if tomorrow a given method might move inside a loop, and
then cause a runaway leak.

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Why is RAII called RAII? Johannes Schaub (litb) C++ 2 09-18-2010 09:18 AM
Re: Why is RAII called RAII? Goran Pusic C++ 11 09-16-2010 03:11 PM
Re: Why is RAII called RAII? cpp4ever C++ 1 09-13-2010 06:25 AM
Design Pattern Relationship Diagram - Design Patterns - Gang of Four Tim Smith C++ 2 12-15-2004 05:22 PM
where to find good patterns and sources of patterns (was Re: singletons) crichmon C++ 4 07-07-2004 10:02 PM



Advertisments