Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 188037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:55:57+00:00 2026-05-11T15:55:57+00:00

This seems like it might be a bad idea, but I can’t figure out

  • 0

This seems like it might be a bad idea, but I can’t figure out why:

I have a class, cXYZ, with properties A, B and C. It also has a method ‘sGetData’ that loads those three properties from the database, and a method ‘sSaveData’ which saves it back.

class cXYZ    public property A as string...   public property B as string...   public property B as string..    public sub sGetData()...   public sub sSaveData()...  end class 

A webform has the following property:

private property xyz() as cXYZ get     return session('myXYZ') end get set (value as cXYZ)     session('myXYZ')=value end set end property 

And the following events:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  if not ispostback() then     xyz=new cXYZ() end if  end sub  Protected Sub ButtonLoad_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonLoad.Click     //Can now reference the class   txtA.text=xyz.A   txtB.text=xyz.B   txtC.text=xyz.C  end sub    Protected Sub ButtonSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonSave.Click    //Can now reference the class   xyz.A=txtA.text   xyz.B=txtA.text   xyz.C=txtC.text    xyz.sSaveData()  end sub 

I can see some overhead with serializing/deserializing for each property reference- it might be worth doing this:

 Protected Sub ButtonSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonSave.Click    dim localxyz as cXYZ=xyz    localxyz .A=txtA.text   localxyz .B=txtA.text   localxyz .C=txtC.text    xyz=localxyz  end sub 

Other than that, views on why this is good or bad? The class is not large, it maintains the form state. Webforms suck, etc is not very useful..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:55:57+00:00Added an answer on May 11, 2026 at 3:55 pm

    I would improve that little bit:

     private _xyz as cXYZ = nothing    private property xyz() as cXYZ     get       if _xyz is nothing then _xyz = TryCast(session('myXYZ'), cXYZ)       return _xyz    end get     set (value as cXYZ)       _xyz = value       session('myXYZ')=_xyz     end set end property 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok this might seems a bad idea or an obvious one. But let's imagine
This might sound like an obvious question but I can't seem to find the
This seems like the simplest Git question, but I can't find ANYTHING on it.
This might seem like a very easy question for some of you folks, but
This might seem like a weird question, but bear with me. I'd like to
This might seem like a trivial question, but I'm a bit muddled in my
I know this might seem like a duplicate, but I'm not getting anywhere with
This seems like a repeated question but i'm not able to get my answer.
This seems like such a simple issue but I cannot find an elegant solution.
This seems like something that could be quite useful and yet and I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.