Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

Performance question

I have my main page, Default.aspx. This page loads user controls in the body, based
on query string values:

Private Sub Page_Load
      Dim departmentId As String = Request.QueryString("departmentID")
      Dim viewCart As String = Request.QueryString("ViewCart")
      Dim categoryId As String = Request.QueryString("CategoryID")
      Dim searchString As String = Request.QueryString("Search")
      Dim Ly As String = Request.QueryString("Ly")

      If Not viewCart Is Nothing Then
         Dim control As Control
         control = Page.LoadControl("UserControls/ShoppingCart.ascx")
         pageContentsCell.Controls.Add(control)
      ElseIf Not searchString Is Nothing Then
      ......
      ElseIf Not categoryId Is Nothing Then
      ......

My question is: Is declaring and assigning 5 string variables everytime the page is loaded
bad for performance?  The application performs well now . . . but I'm not sure how it will
with high traffic.  And I was thinking of adding a few more variables to the page load,
making it 7 variables instead of 5.
0
MikeMCSD
Asked:
MikeMCSD
3 Solutions
 
praneethaCommented:
hmm do u think it will really affect the performance..hmm don't think so...
0
 
b1xml2Commented:
Strings are value types and immutable. mmmm....no impact on performance, the way you have done it, although from a pattern design point of view, wouldnt it be nicer to have properties for the QueryString Parameters ?
like so:

Private ReadOnly Property DepartmentID() As String
      Get
            Dim value As String = String.Empty
            If Not Request.QueryString("departmentID") Is Nothing Then
                  value = Request.QueryString("departmentID")
            End If
      End Get
End Property

They feel like properties and should be coded and treated as such. By providing this encapsulation, you can also insert special business logic, say if the DepartmentId is empty, provide a default value... etc etc

I know OO programming requires a shift in thinking but I argue that such a shift is achievable for everyone and if anyone says to you that it takes years to learn OO programming, never believe that!!!
0
 
raterusCommented:
It doesn't really matter for such trivial things such as these assignments.  Now when you are talking about the difference between the page loading in 2seconds vs. 20seconds, then you can get into performance discussions. :-)
0
 
b1xml2Commented:
just for completeness

Private ReadOnly Property DepartmentID() As String
      Get
            Dim value As String = String.Empty
            If Not Request.QueryString("departmentID") Is Nothing Then
                  value = Request.QueryString("departmentID")
            End If
            Return value
      End Get
End Property
0
 
MikeMCSDAuthor Commented:
thanks all . . I didn't think this was a performance issue but wasn't absolutely sure.
b1xml2, thanks for the OO explanation . . I have the basics of OO, but I still think
as a VB programmer :-)    I'll try the Property code.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now