473,418 Members | 1,933 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,418 software developers and data experts.

Local Table vs. Class for Public Variables with simple types

I have a question based somewhat on:

http://groups.google.com/group/comp....2bbc027bf00720

A local table works well as a poor-man's repository for public
variables with simple 'Types.' What are the relative merits of
creating a class or collection versus using a local table?

James A. Fortune

Dec 9 '05 #1
12 1668
I'm not really answering your question (aplogies) but
I have used custom properties of the database or in access >=2000 of
the current project.
Advantages:
1. They persist and are available on opening the application (that is
we can save a user's preferences) ;
2. The belong to the front end so not worry about differentiatings
John's from Jean's.

Dec 9 '05 #2
A local table has the same advantages. Do the custom properties have
an advantage that is not shared by a local table?

James A. Fortune

Dec 9 '05 #3
The main thing is persistence.

If you are simply persisting static values then it doesn't matter what you
use.

I you are persisting values which can be altered by the user (i.e. user
settings) then you need to persist to something which can be written to.
Typical examples include:-
Data tables
Ini Files
Plain text files
Registry (especially using GetSetting/SaveSetting)
Database properties


--
Terry Kreft

<ji********@compumarc.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
I have a question based somewhat on:

http://groups.google.com/group/comp....2bbc027bf00720

A local table works well as a poor-man's repository for public
variables with simple 'Types.' What are the relative merits of
creating a class or collection versus using a local table?

James A. Fortune

Dec 9 '05 #4
I've used custom properties also, though not recently. The advantage,
in my opinion, is that the syntax for retrieving them is simpler ...

strUser = GetProperty("username")

as opposed to
strUser = Dlookup("[UserName]","[tblMyProperties]")

Perhaps it's only slightly simpler, but I always felt it was easier to
remember the syntax for my property calls. Mind you, the GetProperty
call is not a native Access function, but something I encapsulated, so
it's not like you can cut and paste that call and have it work. I'm only
speaking to the ease with which it can be done. I suppose you could
do the same with the DLookup() call, or create a class to get the props
from a table.
--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com/datafast
<ji********@compumarc.com> wrote ...
A local table has the same advantages. Do the custom properties have
an advantage that is not shared by a local table?

James A. Fortune

Dec 9 '05 #5
Terry Kreft wrote:
The main thing is persistence.

If you are simply persisting static values then it doesn't matter what you
use.

I you are persisting values which can be altered by the user (i.e. user
settings) then you need to persist to something which can be written to.
Typical examples include:-
Data tables
Ini Files
Plain text files
Registry (especially using GetSetting/SaveSetting)
Database properties


I think the Data tables and Database properties have an advantage over
the others since the changes are contained within the mdb file itself.
What do you think about storing information in an XML file for more
complicated objects?

James A. Fortune

I think in (american) football there's a mistaken idea that you can get
by with average offensive and defensive linemen if you have a star
quarterback, star receivers and a star running back. I have lots of
patience, rather, for any team that picks linemen high in the draft.
Those offensive linemen will turn average QB's, running backs and
receivers into stars. Those defensive linemen will turn the other
team's QB's, running backs and receivers into losers.

Dec 9 '05 #6
Danny J. Lesandrini wrote:
I've used custom properties also, though not recently. The advantage,
in my opinion, is that the syntax for retrieving them is simpler ...

strUser = GetProperty("username")

as opposed to
strUser = Dlookup("[UserName]","[tblMyProperties]")

Perhaps it's only slightly simpler, but I always felt it was easier to
remember the syntax for my property calls. Mind you, the GetProperty
call is not a native Access function, but something I encapsulated, so
it's not like you can cut and paste that call and have it work. I'm only
speaking to the ease with which it can be done. I suppose you could
do the same with the DLookup() call, or create a class to get the props
from a table.
--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com/datafast


Thanks. That gives me a better idea of the tradeoffs.

James A. Fortune

Dec 9 '05 #7
Let's see:
1. assuming be/fe split they won't require a third file;
2. regardless of fe/be split their existence will seldom make
compacting required;
3. they are accessible in one line of code without recordset connection
query etc;
4. one sees horror stories in cdma about local tables; one sees fewer
horror stories about custom properties;
5. they may be inherently more private (in the sense that it's unlkely
Sally will see them unless she knows where to look and what to look for
or is clever enough to walk the properties collection) even if she
opens Fred's file;
6. the IT department will never know they exist; hence the IT
department won't screw them up sometime just because they CAN!;
7. in access >= 2000 they can be assigned to access objects
(trivial examples below)

CurrentProject.AllForms(Me.Name).Properties.Add "SomeName", 23

MsgBox CurrentProject.AllForms(Me.Name).Properties("SomeN ame")

If CurrentProject.AllForms(Me.Name).Properties("SomeN ame") = 23 Then
'do something
End If

CurrentProject.AllForms(Me.Name).Properties.Remove "SomeName"

Dec 9 '05 #8
I also use the ADO recordset Save method. It's very simple and very
fast; The recordset can be reconstructed with the Open method. It
requires only a few lines of code.

Dec 9 '05 #9
"Danny J. Lesandrini" <dl*********@hotmail.com> wrote in
news:q-********************@giganews.com:
I've used custom properties also, though not recently. The
advantage, in my opinion, is that the syntax for retrieving them
is simpler ...

strUser = GetProperty("username")

as opposed to
strUser = Dlookup("[UserName]","[tblMyProperties]")

Perhaps it's only slightly simpler, but I always felt it was
easier to remember the syntax for my property calls. Mind you,
the GetProperty call is not a native Access function, but
something I encapsulated, so it's not like you can cut and paste
that call and have it work. I'm only speaking to the ease with
which it can be done. I suppose you could do the same with the
DLookup() call, or create a class to get the props from a table.


You could very easily write a GetProperty function that internally
did a DLookup, so there really is no issue here of GetProperty being
easier.

My feeling is that retrieving custom properties of the MDB is slower
than retrieving data from a table.

Either way, I'd wrap both in a self-healing class module and
initialize it at startup and then use the class module to get the
settings.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Dec 10 '05 #10
I wasn't reccomending any particular method. I would agree that database
properties and tables are better because they are carried with the database.

If I was storing more complicated objects e.g. I wanted to persist the state
of a class module (or form) then XML may well be the way to go, personally
though I would look at tables or property bags.

The advantage of a property bag is that you can store it whereever you want
so you can persist it to a file, or the registry or a database field. They
are less easy to "crack" than XML as well.

You could use an ADO stream and persist that to a field in a table as well.
e.g.

(BTW this is a horrible cludgy piece of code which I've knocked up because
I've only just thought of this as a method, so no digs on the style please)

Function ADOStream()
Dim rs1 As ADODB.Recordset
Dim rs2 As ADODB.Recordset
Dim stm As ADODB.Stream
Dim strTest As String

Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Set stm = New ADODB.Stream

rs1.Open "SELECT * FROM Customers", "Provider=sqloledb;" & _
"Data Source=wmpsdeterry3;Initial Catalog=Northwind;" & _
"User Id=sa;Password=;""", adOpenStatic, adLockReadOnly, adCmdText

rs1.Save stm, adPersistXML

strTest = stm.ReadText

rs2.Open "SELECT * FROM tblPersist WHERE 1=0", CurrentProject.Connection,
adOpenDynamic, adLockOptimistic

With rs2
.AddNew
.Fields("persist").AppendChunk strTest
.Update
End With
End Function

Function GetItBack()
Dim rs1 As ADODB.Recordset
Dim rs2 As ADODB.Recordset
Dim stm As ADODB.Stream
Dim strTest As String

Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Set stm = New ADODB.Stream

rs2.Open "SELECT * FROM tblPersist WHERE [id]=1",
CurrentProject.Connection

With rs2.Fields("persist")
strTest = .GetChunk(.ActualSize)
End With
stm.Open
Call stm.WriteText(strTest)
stm.Position = 0
rs1.Open stm
End Function

--
Terry Kreft

<ji********@compumarc.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Terry Kreft wrote:
The main thing is persistence.

If you are simply persisting static values then it doesn't matter what
you
use.

I you are persisting values which can be altered by the user (i.e. user
settings) then you need to persist to something which can be written to.
Typical examples include:-
Data tables
Ini Files
Plain text files
Registry (especially using GetSetting/SaveSetting)
Database properties


I think the Data tables and Database properties have an advantage over
the others since the changes are contained within the mdb file itself.
What do you think about storing information in an XML file for more
complicated objects?

James A. Fortune

I think in (american) football there's a mistaken idea that you can get
by with average offensive and defensive linemen if you have a star
quarterback, star receivers and a star running back. I have lots of
patience, rather, for any team that picks linemen high in the draft.
Those offensive linemen will turn average QB's, running backs and
receivers into stars. Those defensive linemen will turn the other
team's QB's, running backs and receivers into losers.

Dec 10 '05 #11
Terry Kreft wrote:
I wasn't reccomending any particular method. I would agree that database
properties and tables are better because they are carried with the database.

If I was storing more complicated objects e.g. I wanted to persist the state
of a class module (or form) then XML may well be the way to go, personally
though I would look at tables or property bags.

The advantage of a property bag is that you can store it whereever you want
so you can persist it to a file, or the registry or a database field. They
are less easy to "crack" than XML as well.

You could use an ADO stream and persist that to a field in a table as well.
e.g.

(BTW this is a horrible cludgy piece of code which I've knocked up because
I've only just thought of this as a method, so no digs on the style please)

Function ADOStream()
Dim rs1 As ADODB.Recordset
Dim rs2 As ADODB.Recordset
Dim stm As ADODB.Stream
Dim strTest As String

Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Set stm = New ADODB.Stream

rs1.Open "SELECT * FROM Customers", "Provider=sqloledb;" & _
"Data Source=wmpsdeterry3;Initial Catalog=Northwind;" & _
"User Id=sa;Password=;""", adOpenStatic, adLockReadOnly, adCmdText

rs1.Save stm, adPersistXML

strTest = stm.ReadText

rs2.Open "SELECT * FROM tblPersist WHERE 1=0", CurrentProject.Connection,
adOpenDynamic, adLockOptimistic

With rs2
.AddNew
.Fields("persist").AppendChunk strTest
.Update
End With
End Function

Function GetItBack()
Dim rs1 As ADODB.Recordset
Dim rs2 As ADODB.Recordset
Dim stm As ADODB.Stream
Dim strTest As String

Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Set stm = New ADODB.Stream

rs2.Open "SELECT * FROM tblPersist WHERE [id]=1",
CurrentProject.Connection

With rs2.Fields("persist")
strTest = .GetChunk(.ActualSize)
End With
stm.Open
Call stm.WriteText(strTest)
stm.Position = 0
rs1.Open stm
End Function

--
Terry Kreft


Terry,

I admit that I've never considered using an ADO stream saved in a table
for that purpose before. I will consider the idea carefully. The data
I persist is not usually sensitive but your point about the readability
of XML is an important one. Thanks for sharing your opinions on
persistence.

James A. Fortune

Dec 12 '05 #12
Lyle Fairfield wrote:
Let's see:
1. assuming be/fe split they won't require a third file;
2. regardless of fe/be split their existence will seldom make
compacting required;
3. they are accessible in one line of code without recordset connection
query etc;
4. one sees horror stories in cdma about local tables; one sees fewer
horror stories about custom properties;
5. they may be inherently more private (in the sense that it's unlkely
Sally will see them unless she knows where to look and what to look for
or is clever enough to walk the properties collection) even if she
opens Fred's file;
6. the IT department will never know they exist; hence the IT
department won't screw them up sometime just because they CAN!;
7. in access >= 2000 they can be assigned to access objects
(trivial examples below)

CurrentProject.AllForms(Me.Name).Properties.Add "SomeName", 23

MsgBox CurrentProject.AllForms(Me.Name).Properties("SomeN ame")

If CurrentProject.AllForms(Me.Name).Properties("SomeN ame") = 23 Then
'do something
End If

CurrentProject.AllForms(Me.Name).Properties.Remove "SomeName"


Thanks for the list Lyle. Although none of the items in this list
concern me at the moment, #7 will be particularly cogent once I no
longer have to support A97 (don't even go there :-)). It looks like
custom properties are a nice way to go.

James A. Fortune

Dec 12 '05 #13

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

Similar topics

12
by: Olumide | last post by:
I'm studying Nigel Chapman's Late Night Guide to C++ which I think is an absolutely fantastic book; however on page 175 (topic: operator overlaoding), there the following code snippet: inline...
5
by: Chris | last post by:
Hi, I don't get the difference between a struct and a class ! ok, I know that a struct is a value type, the other a reference type, I understand the technical differences between both, but...
3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
16
by: Jm | last post by:
Hi All Is it possible to determine who is logged onto a machine from inside a service using code in vb.net ? I have found some code that seems to work under vb6, but doesnt under .NET ? Any help...
13
by: cgough | last post by:
My true programming language is C++. I am at best a VB6 hacker that is just getting into VB.NET. I have a quick question about when to new and when not to new. Consider the following 2 classes....
55
by: Zytan | last post by:
I see that static is more restricted in C# than in C++. It appears usable only on classes and methods, and data members, but cannot be created within a method itself. Surely this is possible in...
5
by: tshad | last post by:
In VS 2003, I am setting up an abstract class that is setting up classes for each datatype of VB.Net (as well as C#). I am trying to set it up so that most of the work is done in the Abstract...
20
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
4
by: JNeko | last post by:
hello all, I have tried my hand at this for a couple hours but no luck. I am using JCreator. I used these two links for reference: http://www.tech-recipes.com/java_programming_tips1265.html...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.