[AccessD] Basic Unbound Form with Classes and Collections Par t1.

Heenan, Lambert Lambert.Heenan at AIG.com
Mon Jun 12 12:48:14 CDT 2006


" Putting in Get and Let statements, with a class level module dimensioned
would actually just be wasted lines of code in this demo project."

... But not as much of a waste of time as the process of explaining later on
why public members fields have drawbacks. That they cause problems that the
whole OOP methodology was designed to eliminate. In short, why try to teach
the use of classes by beginning with an example which is bad programming.
I'm sorry to have to contradict you there, but globals are bad news in any
context, and they are especially bad when they negate the major advantage of
using a class - data encapsulation, one of the  two main reasons to use
classes, the other being simplified code reuse.

Especially in VB/VBA, a public member declaration looks exactly the same as
a public variable declaration in a standard module. By using this as an
example of a class the newbie is then faces with the puzzle of why there are
different syntaxes for accessing the data. The answer is "because it's a
class member", but little is learned from this fact.

If instead you go to the trouble of declaring a couple of Get and Let
properties, which will only take a couple of lines each, not thousands of
them, then a much clearer idea of what a property is can be conveyed. "But
you do agree that using Public in a class is essentially a property", well
no. It's a "property" of sorts, but more than that it's a gaping hole in a
class definition that invites unintended side-effect, aka 'bugs'.

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of DWUTKA at marlow.com
Sent: Monday, June 12, 2006 11:42 AM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Basic Unbound Form with Classes and Collections Par
t1.


Have you ever taught before Lambert?  We had a few people request a demo. If
I started off with all of everything in the first lesson, most people
wouldn't pick it up, in fact, they would probably shy away, and stick with
even less 'mature' coding.  You have to learn to crawl before you can walk.
If I had given them their first class module with a thousand lines of code,
they'd run away.  I give them their first class with a few lines of code,
and they can go 'gosh, that was simple', and it pulls them into the lesson.

I do not like your comparison of that class to using a goto statement in a
while loop.  Not even close.  Yes, it's simplified, but it did EXACTLY what
it was supposed to do, and was not BAD programming, just beginning
programming.  Putting in Get and Let statements, with a class level module
dimensioned would actually just be wasted lines of code in this demo
project.

Waste not, want not.

Drew

-----Original Message-----
From: Heenan, Lambert [mailto:Lambert.Heenan at aig.com] 
Sent: Monday, June 12, 2006 8:16 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Basic Unbound Form with Classes and Collections Par
t1.

Sorry. But I'd say it's a silly class. You might as well try to teach people
how to code in "Basic Basic" by pointing out how Goto can be used to
circumventing the carefully design flow of a execution that loop structures
provide. You can Goto out of a While loop, but it's not advisable if you
want maintainable code.

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust
Sent: Friday, June 09, 2006 5:19 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Basic Unbound Form with Classes and Collections Par
t1.


This is a simplified class, Lambert.  In fact, any public variable in a
class is a property of the class.  You just can't control the usage of that
property.  I'm sure Drew will get to the "proper" approach later. ;o} 


Charlotte

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Heenan, Lambert
Sent: Friday, June 09, 2006 2:01 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Basic Unbound Form with Classes and Collections Par
t1.


<snip>

Our table has three fields, so we'll create three easy properties, and a
fourth which will be derived.

So, in the code page type the following under the 'Option Compare Database'
line:

Public ID As Long
Public FirstName As String
Public LastName As String

[ These are not properties at all, they are class member fields, and making
them public is a Q&D solution which defeats the purpose of data
encapsulation that classes offer. A real property Get and Set pair would
correct this, with the member fields being change to Private]

Lambert
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list