my initial article described how to include the asp object within a server-side vb component so as to capture variables set by a browsers' html form, a url query string, session objects, etc. this made server-side component coding convenient since all the asp objects, and their settings related to each individual visiting browser, were made available to the vb code as global-like variables.
but there was also a downside to this type of server-side component design. i found that managing the many aspects of the asp object from within my components became increasingly complicated as my projects grew. i also found that using property procedures did not add to the management or scalability of my components (property procedures weren't explicitly covered in the previous article so i'll briefly discuss them below).
so the components written in the way described in the previous article had the advantages of having access to all the many variable values provided by the asp object, as well as those that could be sent from an asp file by setting the components' property properties in the manner illustrated below:
asp file code:
<%
aspvariable = "a string example variable sent to the component"
set objreference = server.createobject("projectname.classname")
objreference. examplepropertyprocedure = aspvariable
objreference.classmethod
%>
below is the vb code for the property procedure that will assign the value of the aspvariable variable from the asp code above to the vb component variable named strpropertyprocedure.
vb code:
private strpropertyprocedure as string
public property let examplepropertyprocedure(byval rhs as string)
strpropertyprocedure = rhs
end property
along with the asp object variable values and the components' property procedures, component variables could include values received from databases. so variables used within the previously described vb component had values coming from databases, property procedures, and the numerous inlets provided by the asp object.
not only does a vb component that uses the asp object allow access for variable values going in to the vb code, but the asp response object can be used to return text or html from the vb code back out to the asp file that called it. and the asp response.write() method can be called multiple times from anywhere within the vb code.
previous design:
to summarize, a vb component designed like the one in the previous article will have access to all the variable values coming in to it via the asp object, via property procedures, and via database table fields. it would send variable values out to the asp page via the asp object.
again, the downside to this design was keeping up with the many avenues that a variable could take when being sent in and out of the component. these design complications were increasingly detrimental as a project inevitably grew beyond manageable proportions, not to mention the scalability issues related to the overhead from using property procedures and the asp object within the vb code.
the solution was to forgo instantiating the asp object in the component and eliminating property procedures altogether. the newly designed server-side component reduced the complexity of the previous design to a simple set of classes that contained groups of various similar functioning methods that worked without access to variable values that could be mutually shared. the question was "what was the cleanest way to get variable values to the vb code in from the asp file and back out from the vb component to the asp file?"