TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Matthew Heaney <[log in to unmask]>
Sat, 6 Mar 1999 12:55:24 -0800
Matthew Heaney <[log in to unmask]>
text/plain (50 lines)
The following message is a courtesy copy of an article
that has been posted to comp.lang.ada,comp.object as well.

I have prepared a short article on how to implement the (virtual) proxy
pattern in Ada95, and posted it to the ACM patterns archive.  The
introduction of the article appears below.


I've been slowly converting the C++ examples in the book Design Patterns
to Ada95.  In each article I discuss the pattern, explain how to
implement it in Ada, and explore various idioms and language features.
A complete, working example with all the code is included.

You can subscribe to the patterns list (which is really growing these
days!) by sending a message with the body:

subscribe patterns <your full name>

to the ACM mailing-list server.

<mailto:[log in to unmask]>


Virtual Proxy Pattern

In this article I discuss how to implement the virtual proxy pattern in


We'd like to optimize the amount of time it takes to open an image-rich
document.  The problem now is that every image in the file is getting
streamed in from disk and converted to its in-memory representation, and
this processing takes too long.

We can save start-up time by postponing initialization of an image until
it comes time to actually render it.  This technique is probably
familiar to those of you who have done X Windows programming.  Creating
every single dialog in the application up front can take a while, so you
wait until the user issues a pop-up request and just create the dialog

We perform this optimization by inserting image proxies in our document
instead of images.  An image proxy caches the information necessary to
initialize the image, but delays actual initialization until it receives
a request that can only be handled by the image itself.