    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: Broadvision - Part 2</title>
        <link>https://members.accu.org/index.php/articles/591</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>




<div class="xar-mod-head"><span class="xar-mod-title">Design of applications and programs + Overload Journal #27 - Aug 1998</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c13/">Topics</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c67/">Design</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c78/">Overload</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c176/">27</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/c67-176/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/articles/c67+176/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;Broadvision - Part 2</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 27 August 1999 18:22:42 +01:00 or Fri, 27 August 1999 18:22:42 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e20" id="d0e20"></a>Recap</h2>
</div>
<p>In last issue's piece, I described what Broadvision was and gave
a flavour for how it worked, looking in particular at extending
some of its classes to work around design blind spots. I said that
this time I'd look at database access and encapsulating the
Broadvision API as well as more information on session management.
The pressures of work have meant that I haven't had much time to
prepare this piece as I'd like - ironically, I'm working on another
Broadvision-powered web site and it's keeping me very busy!</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e25" id="d0e25"></a>Sessions</h2>
</div>
<p>I touched briefly on the concept of web site sessions in the
first article in this series and in order to explain what follows,
I shall elaborate a little on session management. The web is
essentially stateless: you visit a site, the browser requests the
page, the server fetches (or generates) it and sends it to your
browser. At that point, you can request another page from that site
or another and the browser maintains only a history of which pages
you've requested. The server on the other hand, spends its time
fetching or generating pages in response to requests from any
number of users. For a personalised web experience, someone has to
maintain information about your choices within a web site, for
example a 'shopping basket' within an e-commerce (electronic
commerce) web site.</p>
<p>Broadvision chooses to maintain this session 'state' information
on the server. When you connect to a Broadvision site, it allocates
a unique session 'ID' and uses it in every generated link and form
so that with each incoming request, it can work out which of its
currently active users is making the request. Naturally, an
application built using Broadvision will need to maintain its own
state information: an example from our travel site is the set of
destination / price range / date range choices that you make as you
wander around the site.</p>
<p>Broadvision provides a very simple interface for application
data: an associative array of strings called the application data
dictionary. In C++ terms, this is effectively
map&lt;string,string&gt; but wrapped up in a session ID based
lookup mechanism (i.e., map&lt; SessionID, map&lt;string,string&gt;
&gt;). The base Broadvision class, Dyn_Object, provides
'store_app_data' and 'find_app_data' methods to access the
application dictionary (thus hiding the session ID lookup - the
object already knows about session IDs).</p>
<p>The first part of the application we tackled was the foreign
currency section of the site. We needed to store the user's choices
of currency and amounts for the conversion process. We tried to fit
in with Broadvision's application dictionary by mapping our array
of currencies, rates and amounts down to strings and then
converting them back when we needed them. It worked but it was
painfully ugly and very inefficient. I looked in vain for a more
generic way to deal with state data - Broadvision had none.</p>
<p>After a bit of thought about the way Broadvision worked, I
realised that I could solve the problem with static member data -
the Broadvision CGI application ran continuously in the background
so static data would have a suitable lifetime. So I wrote a small
template class called 'SessionStore&lt;T&gt;' to store data of type
'T'. Since I could now store arbitrarily complex data structures on
a per session basis, I decided to allow only a single object of
each type to be stored for any one session and to have it accessed
through a writable reference, i.e., the one and only copy of each
state object for a session lived in its own 'SessionStore'
container. We didn't bother rewriting the currency handler - after
all, it worked and we were somewhat pressed for time - but we used
the new 'SessionStore' for our search context objects and our
customised shopping basket. It's a trivial template class and it
seems an obvious omission from the Broadvision framework. Another
design blind spot.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e38" id="d0e38"></a>See API?</h2>
</div>
<p>I've been very critical about many aspects of the Broadvision
architecture, taking up design issues with everyone from technical
support up through the development team in the USA. One of my main
gripes about the architecture was that most of the API smelled like
C. You know what I mean, you've seen this in other frameworks: a
huge slab of unrelated API calls disguised as methods in an
umbrella class. Broadvision suffers from this in spades: pretty
much the entire session management API lives in one class. In fact,
it goes further than just session management, it also includes
database access functions and many other tasks.</p>
<p>Naturally, I don't like this. If I'd wanted that architecture,
I'd be programming in C. I like C++ because it can provide a better
match to the problem domain by encapsulation. Part of our
application generates emails from the web site to back office staff
containing certain details of the user's profile (name, address
etc). As part of our OO design, we wanted to pass a UserProfile
object into the EmailRequest object so that it could interrogate
the profile to fill out fields in the email message. Broadvision
doesn't have a UserProfile object, instead it provides the
equivalent of get_user_profile_field / set_user_profile_field as
API calls. UserProfile became the first of many classes that we
created to wrap up parts of the API so we could pass suitable
objects around within our application. Like many such wrapping
classes it is rather crude and was tedious to write:</p>
<pre class="programlisting">
class UserProfile
{
public:
  UserProfile() { }
  RWCString name() const
  {
  return get_user_profile_field(&quot;NAME&quot;); 
  }
  UserProfile&amp; name(RWCString n)
  {
    set_user_profile_field(&quot;NAME&quot;,n);
    return *this;
  }
  // about a dozen similar methods
};
</pre>
<p>Now, I don't think of myself as an OO purist, nor do I think I'm
an unreasonable man, but given a framework for an application where
concepts such as 'visitor', 'profile', 'shopping basket' are
absolutely key, doesn't it seem somewhat disappointing that
equivalent classes are not provided within the framework?</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e49" id="d0e49"></a>An object
lesson</h2>
</div>
<p>I'm going off on one of my tangents now, as I'm wont to do. I
mentioned in the 'Recap' that the reason I haven't had as much time
to work on this article as I'd have liked, is that I'm currently
building another Broadvision web site. In fact, I'm not building
it, I'm just designing it: through the vagaries of office politics
and a natural evolution of my position at my client's, I no longer
do any development per se, I'm a designer. I recently evaluated
'Together/J' from Peter Coad's Object International company
(<a href="http://www.oi.com" target=
"_top">http://www.oi.com</a>).</p>
<p>'Together' comes in several flavours dealing with C++ and Java
(and other languages). I chose the Java version because I wanted to
avoid the temptation of generating C++ and then slipping back into
development (our target development language is C++). I downloaded
the Whiteboard edition that provides object diagram functionality
and the ability to browse 'use case' diagrams produced by the full
edition. The object diagram editor has four panes: a navigation
pane showing either a thumbnail of the entire diagram with a
scrollable shadow or a directory hierarchy showing packages and
their contents; an attribute pane allowing direct editing of object
attributes; a diagram pane showing standard UML notation for
classes and relationships; and a code pane showing Java class &amp;
method code for the corresponding elements of the class diagram.
The latter is very slick: change the diagram or attributes and the
code updates immediately, change the code and the diagram and
attributes change to match. The whole product has a very responsive
feel and is very flexible. I was sufficiently impressed to purchase
the full version of the product which adds the ability to create
and edit use case diagrams as well as state and sequence
diagrams.</p>
<p>Using such a UML based CASE tool on a Broadvision project helps
you separate the meat of the design from the continual workarounds
that arise from struggling with the application framework. One of
the first tasks was to create diagrammatic (and, hence, Java)
representations of the main Broadvision classes on which to build
the application-specific classes. It's been a much more pleasant
way to work, being able to concentrate on the design and get that
right. I'd like to think that the rigours of working within a
strict OO design framework have made me a better designer overall
and I'm off on a QA Training course for OOA/D using UML shortly so
I'll probably write up specific pieces both on the course and the
'Together' tool in due course.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e61" id="d0e61"></a>What's
next?</h2>
</div>
<p>We've recently completed the data model for the current project
and we've taken on board much of what we've learnt about
Broadvision over the past year. We're approaching the current
project from a rather different angle to the one I've been
describing here. In the next article, I'll look at database access,
as promised, but with a 'compare &amp; contrast' showing how we
fought with the framework last time and how we're attempting to
work within it this time, hopefully illustrating how suitable
compromises make frameworks more effective. Since we're trying to
stick more closely within Broadvision's framework this time around,
I'll also look at other aspects of Broadvision. In the fourth and
final article in the series, I'll go back to more of the C++
customisation we've done - on both projects - and again, make
comments about blind spots within the framework.</p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
