473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

data persistence - best practice advice

Assume the following:
1) multi-user environment
2) when user opens app, want to run some code that retrieves some
information specific to the user...retrieving this information is
somewhat i/o intensive, so would prefer to retrieve the info once at
the beginning of the session, and have the data persist for the
session
3) several forms in the app need to reference the information
retrieved in #2 (the information specific to the user)
4) would prefer to have a solution where the information specific to
the user (the info retrieved in #2) is NOT stored in a table...instead
the information is stored in a VB data structure, and the VB code is
organized such that:
a) the data structure gets initialized when the user opens the app
b) the information in the data structure persists while the user has
the app open
c ) the data structure is such that the code behind the forms that
need the data have 'visibility' to the data in that data structure

So, my questions are:
1) Is there a 'best practices' way of setting up the VB data structure
to handle the situation described above? If so, what would the
outline of that be for this situation?
2) Is this, perhaps, a good candidate for the use of a class module?

Thank you.
Dec 6 '07 #1
6 2741
mi************@yahoo.com wrote:
Assume the following:
1) multi-user environment
2) when user opens app, want to run some code that retrieves some
information specific to the user...retrieving this information is
somewhat i/o intensive, so would prefer to retrieve the info once at
the beginning of the session, and have the data persist for the
session
3) several forms in the app need to reference the information
retrieved in #2 (the information specific to the user)
4) would prefer to have a solution where the information specific to
the user (the info retrieved in #2) is NOT stored in a table...instead
the information is stored in a VB data structure, and the VB code is
organized such that:
a) the data structure gets initialized when the user opens the app
b) the information in the data structure persists while the user has
the app open
c ) the data structure is such that the code behind the forms that
need the data have 'visibility' to the data in that data structure

So, my questions are:
1) Is there a 'best practices' way of setting up the VB data structure
to handle the situation described above? If so, what would the
outline of that be for this situation?
2) Is this, perhaps, a good candidate for the use of a class module?

Thank you.
Class module or just a hidden form with various controls to hold the values.
You could use global variables but they can lose their values if an unhandled
error occurs (MDB, not MDE). Class objects and hidden forms would not have this
issue.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Dec 6 '07 #2
On Wed, 5 Dec 2007 17:26:14 -0800 (PST), mi************@yahoo.com
wrote:

YES! This is perfect for a class module. There is nothing wrong with
declaring a more classic Type and having a global variable reference
it, but an object representing the user is much more elegant and
versatile.

Start your application with an AutoExec macro (rather than a startup
form). It has just one command: RunCode, InitApplication()
In a standard module write the public function InitApplication, which
as part of its processing (before opening the first form) creates a
global user object of the type referenced in your class module, and
populates it, perhaps by calling an Init method.
Then throughout your app you have access to that object through the
global variable. g_User.FirstName, etc.

-Tom.
>Assume the following:
1) multi-user environment
2) when user opens app, want to run some code that retrieves some
information specific to the user...retrieving this information is
somewhat i/o intensive, so would prefer to retrieve the info once at
the beginning of the session, and have the data persist for the
session
3) several forms in the app need to reference the information
retrieved in #2 (the information specific to the user)
4) would prefer to have a solution where the information specific to
the user (the info retrieved in #2) is NOT stored in a table...instead
the information is stored in a VB data structure, and the VB code is
organized such that:
a) the data structure gets initialized when the user opens the app
b) the information in the data structure persists while the user has
the app open
c ) the data structure is such that the code behind the forms that
need the data have 'visibility' to the data in that data structure

So, my questions are:
1) Is there a 'best practices' way of setting up the VB data structure
to handle the situation described above? If so, what would the
outline of that be for this situation?
2) Is this, perhaps, a good candidate for the use of a class module?

Thank you.
Dec 6 '07 #3
rkc
Tom van Stiphout wrote:
On Wed, 5 Dec 2007 17:26:14 -0800 (PST), mi************@yahoo.com
wrote:

YES! This is perfect for a class module. There is nothing wrong with
declaring a more classic Type and having a global variable reference
it, but an object representing the user is much more elegant and
versatile.

Start your application with an AutoExec macro (rather than a startup
form). It has just one command: RunCode, InitApplication()
In a standard module write the public function InitApplication, which
as part of its processing (before opening the first form) creates a
global user object of the type referenced in your class module, and
populates it, perhaps by calling an Init method.
Then throughout your app you have access to that object through the
global variable. g_User.FirstName, etc.

-Tom.
Better yet is a public function that returns a reference to a private
User object. That way the object can be returned when it exists or
created and initialized if it doesn't. There's no need to create it at
startup. It's created the first time it is used.
Dec 6 '07 #4
On Wed, 05 Dec 2007 22:00:11 -0500, rkc <rk*@rkcny.yabba.dabba.do.com>
wrote:

That's a good idea in some appliations, but the OP wrote:
"when user opens app, want to run some code that retrieves some
information specific to the user", so I fugured it would be
appropriate to initialize the object at startup time.

Do you have a code sample of the finer points of your implementation?

-Tom.
>Tom van Stiphout wrote:
>On Wed, 5 Dec 2007 17:26:14 -0800 (PST), mi************@yahoo.com
wrote:

YES! This is perfect for a class module. There is nothing wrong with
declaring a more classic Type and having a global variable reference
it, but an object representing the user is much more elegant and
versatile.

Start your application with an AutoExec macro (rather than a startup
form). It has just one command: RunCode, InitApplication()
In a standard module write the public function InitApplication, which
as part of its processing (before opening the first form) creates a
global user object of the type referenced in your class module, and
populates it, perhaps by calling an Init method.
Then throughout your app you have access to that object through the
global variable. g_User.FirstName, etc.

-Tom.

Better yet is a public function that returns a reference to a private
User object. That way the object can be returned when it exists or
created and initialized if it doesn't. There's no need to create it at
startup. It's created the first time it is used.
Dec 6 '07 #5
On Wed, 5 Dec 2007 19:47:10 -0600, "Rick Brandt"
<ri*********@hotmail.comwrote:

Agreed on the hidden form, but the class object is likely referenced
by a global variable, which would suffer from the same "unhandled
error" issue.

-Tom.

>mi************@yahoo.com wrote:
>Assume the following:
1) multi-user environment
2) when user opens app, want to run some code that retrieves some
information specific to the user...retrieving this information is
somewhat i/o intensive, so would prefer to retrieve the info once at
the beginning of the session, and have the data persist for the
session
3) several forms in the app need to reference the information
retrieved in #2 (the information specific to the user)
4) would prefer to have a solution where the information specific to
the user (the info retrieved in #2) is NOT stored in a table...instead
the information is stored in a VB data structure, and the VB code is
organized such that:
a) the data structure gets initialized when the user opens the app
b) the information in the data structure persists while the user has
the app open
c ) the data structure is such that the code behind the forms that
need the data have 'visibility' to the data in that data structure

So, my questions are:
1) Is there a 'best practices' way of setting up the VB data structure
to handle the situation described above? If so, what would the
outline of that be for this situation?
2) Is this, perhaps, a good candidate for the use of a class module?

Thank you.

Class module or just a hidden form with various controls to hold the values.
You could use global variables but they can lose their values if an unhandled
error occurs (MDB, not MDE). Class objects and hidden forms would not have this
issue.
Dec 6 '07 #6
rkc <rk*@rkcny.yabba.dabba.do.comwrote in
news:47**********************@roadrunner.com:
Better yet is a public function that returns a reference to a
private User object. That way the object can be returned when it
exists or created and initialized if it doesn't. There's no need
to create it at startup. It's created the first time it is used.
I'm not sure what you mean by a private "User object." You can write
functions that return values stored anywhere, and if they are data
that doesn't change during a user session, then you can use a STATIC
variable in the function and initialize it the first time the
function is called (though that doesn't work with Boolean
variables). I use this technique all the time so that things like
Windows logon and workstation name get looked up only once, the
first time the function is called.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Dec 6 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

131
by: Peter Foti | last post by:
Simple question... which is better to use for defining font sizes and why? px and em seem to be the leading candidates. I know what the general answer is going to be, but I'm hoping to ultimately...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
13
by: Mark Anthony Spiteri | last post by:
Hi, I am designing an ASP.NET application in which particular pages require global variables that need to be persisted during postbacks. What is the best practice to do this? Is it to use the...
5
by: Rod | last post by:
I've written 2 ASP.NET applications (I've worked on one with a team and another by myself). In my ASP.NET pages, when saving data to a backend database I've done it by using the click event of a...
3
by: Marc Gravell | last post by:
Kind of an open question on best-practice for smart-client design. I'd really appreciate anyones views (preferably with reasoning, but I'll take what I get...). Or if anybody has any useful links...
13
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
4
by: Ned Balzer | last post by:
Hi all, I am pretty new to asp.net; I've done lots of classic asp, but am just beginning to get my mind wrapped around .net. What I'd like to do is include some code that tests if a user is...
13
by: G | last post by:
Hello, Looking for opinions on a fairly simple task, new to ASP.net (C#) and want to make sure I do this as efficiently as possible. I have a web based form, and I need to run some SQL before...
3
by: Froefel | last post by:
Hi group I am creating a web application that uses a simple DAL as an ObjectDataSource. To retrieve data from the database, I use a DataReader object from which I then assign the various fields...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.