class modules vs. user interface objects (1 Viewer)

vba_php

Forum Troll
Local time
Yesterday, 21:49
Joined
Oct 6, 2019
Messages
2,880
relating to this thread: https://www.access-programmers.co.uk/forums/showthread.php?t=307794,

....this is exactly why I don't use many class modules (see attached accdb). why would I create the class modules that are in the attached sample ("employee" and "payroll"), fill the members with data and throw that data into a form display (forms "Employment Application1" and "Payroll Preparation1") when I can do the exact same thing by creating tables (tables "employee" and "payroll"), running a simple query to get the calculated total (query "payroll_calculations"), and displaying all the related data in a form (form "payroll_calculations")? seems to me that method #2 would seem a lot easier, especially for newbies.

sample replicated from this illustration: http://www.functionx.com/vbaccess/Lesson05.htm
 

Attachments

  • class module example.zip
    39.2 KB · Views: 102
Last edited:

moke123

AWF VIP
Local time
Yesterday, 22:49
Joined
Jan 11, 2013
Messages
3,912
Your example only brushes the surface and I dont think you went far enough into the FunctionX article. In the class there would be properties and methods to do various things with the data.

I've only used some custom classes for a few limited things and partially as a learning experience. For the most part much of what I've used them for could easily be accomplished using standard subs and functions but what fun would that be.

For instance I use a custom class to return certain default values for objects on my forms (Combo boxes, list boxes, values which may not be available in the recordsource of the form) If I need to add an additional default value at a later time it is rather easy to incorporate it into the class.
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 22:49
Joined
May 21, 2018
Messages
8,525
You kind of missed the point of the article. The author was not suggesting that rebuilding Access functionality was a good use of custom classes, they were just using that as an illustrative means to explain how to create and use classes. So your argument that you do not understand or use custom classes because this article showed limited utility makes no sense. If you want to understand the utility of classes you should look at many of my threads. I code stuff that you would never be able to do, but any user can easily use them with very little code.
 

vba_php

Forum Troll
Local time
Yesterday, 21:49
Joined
Oct 6, 2019
Messages
2,880
For the most part much of what I've used them for could easily be accomplished using standard subs and functions but what fun would that be.
well a lot of times moke, I write stuff with the next person in mind. Given the fact that I work for some pretty uneducated people sometimes, if they ever did hire their own programmer in the future after I let them go out on their own, the programmer would obviously have to follow what I did and for them it would make perfect sense to read something that I did in the easiest and least stressful manner possible.

I've written plenty of custom class oriented script, but not once did I do it because I felt like "what fun is there in doing it an easier way?" like you stated. My goal is always, and will always be, to make things as painless as possible on the person(s) bringing in the money. And it makes good sense too, because after all, they're the ones writing my checks.
 

moke123

AWF VIP
Local time
Yesterday, 22:49
Joined
Jan 11, 2013
Messages
3,912
My reference to "Fun" was intended to mean its fun to learn new things.

I find using classes for my purposes makes coding easier, more portable, and easier to follow. Its all in one place and adding to it requires only a few lines of code.

Granted I'm struggling to incorporate more custom events into my classes but I have a feeling MajP is going to be helping me with that in the future:D
 

vba_php

Forum Troll
Local time
Yesterday, 21:49
Joined
Oct 6, 2019
Messages
2,880
I find using classes for my purposes makes coding easier, more portable, and easier to follow. Its all in one place and adding to it requires only a few lines of code.
If you don't already know this, I think you'll find that almost anyone who goes to school and is trained in this business will insist that there is no other way to do things that this way. That's all they know, and that's what they are told is "proper" by those high-level university professors that do all the research.
 

Cronk

Registered User.
Local time
Today, 12:49
Joined
Jul 4, 2013
Messages
2,771
I'm with Moke on this. Now I create an object for every significant entity. There is a bit of overhead in setting the object up but then instead of using

Code:
"select * form Person where PersonID=" & PersonID
multiple times throughout my code, it's a simple matter to use
Code:
set objPerson= Person.load(PersonID)
and then all of the objects properties are available intellisense. Saves typing and I don't have to remember obscure field names - they are all in the drop down for the object.
No more needing to concatenate first/surnames - just define a custom property and use objPerson.FullName
 

vba_php

Forum Troll
Local time
Yesterday, 21:49
Joined
Oct 6, 2019
Messages
2,880
not a bad point Cronk. I did an interview last Friday where I tool an Oracle test writing SQL statements. I don't this thread applies to that though, as they were still pounding out SQL. I'm not even sure they were able to query out Oracle data using a web language....but at any rate, the interview was pretty disappointing, as there was 5 questions on it and the most advanced ask was to write GROUP BY covering 2 fields of data. :rolleyes:
 

deletedT

Guest
Local time
Today, 03:49
Joined
Feb 2, 2019
Messages
1,218
.... you should look at many of my threads. I code stuff that you would never be able to do....

I'd appreciate if you add several links. I hate AWF's search. It never works. :(
 

vba_php

Forum Troll
Local time
Yesterday, 21:49
Joined
Oct 6, 2019
Messages
2,880
I'd appreciate if you add several links. I hate AWF's search. It never works. :(
actually Tera, I find it quite useful! The highlighting feature is a great identifying tool. What don't you like about it?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 21:49
Joined
Feb 28, 2001
Messages
27,138
Adam, perhaps I can 'splain this one a little better. You know that I treat OOP as just another tool in the tool box. I am of that mindset. It is a tool I don't use very often any more because I'm retired and my home-level programming is more like an inventory than anything else. No need for OOP at this point.

Having said that, you would use OOP styles to create an object when you really wanted certain of its properties and methods to be more tightly associated with the object. When you take the non-OOP approach, it becomes easy to be neglectful. When you take the OOP approach, YES there is a lot of baggage but NO your baggage cannot be sent to the wrong airport (so to speak). It is attached or encapsulated or pick your favorite other strong-binding participial adjective.
 

deletedT

Guest
Local time
Today, 03:49
Joined
Feb 2, 2019
Messages
1,218
What don't you like about it?
https://www.access-programmers.co.uk/forums/showthread.php?t=304101

actually Tera, I find it quite useful! The highlighting feature is a great identifying tool.
Adam, sometimes you disappoint me. You're a php programmer and your handle name is vba_php and this is a vbulletin forum.
And you're surprised by highlighting?

You can add &highlight=keyword to the end of each address to highlight whatever you want.
https://www.access-programmers.co.uk/forums/showthread.php?t=308549&highlight=class
 

vba_php

Forum Troll
Local time
Yesterday, 21:49
Joined
Oct 6, 2019
Messages
2,880
Adam, sometimes you disappoint me. You're a php programmer and your handle name is vba_php and this is a vbulletin forum.
And you're surprised by highlighting?

You can add &highlight=keyword to the end of each address to highlight whatever you want.
https://www.access-programmers.co.uk/forums/showthread.php?t=308549&highlight=class
I know *that* Tera! But I hardly ever manipulate the URL query string when I can click buttons and make it easy on myself. :p I hate un-necessary difficulties. Remember, I'm a proponent of Ali's "rope-a-dope" technique and my self-proclaimed "simple-stupid" approach. Actually though, I think the term "simple-stupid" was coined a long time ago, so I'm no innovator in that regard. And by the way, I'm NOT a programmer. I'm a business person. Programming is just a necessary part of the job. It will never be my core competency.

<edit>
and I probably misspoke when I said I don't mess around with the URL in the address bar. Yes, i do all the time. Just the other day I had to explain to some young punk on facebook that this:
Code:
[URL="http://facebook.com/garbage/?comment_id=1029031564127244&moreGarbage"]facebook.com/garbage/?comment_id=1029031564127244&moreGarbage[/URL]
actually indicated the massiveness of facebook's databases because the record ID of the database record that held the comment's content was 30 bytes long! I never heard from him again after issuing that explanation. Perhaps I made him feel bad.....but he was pretty arrogant (kind of like me!) and I had to say something....
 
Last edited:

deletedT

Guest
Local time
Today, 03:49
Joined
Feb 2, 2019
Messages
1,218
I'm a proponent of Ali's "rope-a-dope" technique

At first I regretted what I posted above. I thought you may have been offended by what I wrote and how I said it. But not anymore. I had to google this phrase and I at least learnt something new. (even if it may have offended you). Anything can be a good lesson for a not native English speaker. Thanks for today's lesson. :)
 
Last edited:

vba_php

Forum Troll
Local time
Yesterday, 21:49
Joined
Oct 6, 2019
Messages
2,880
(even if it may have offended you)
I think what you'll find as time rolls on in this place, is that I rarely, if ever, get offended by anything. Not even when my father uses the 'n' word right in front of my face. and he does it constantly. :rolleyes:
 

Users who are viewing this thread

Top Bottom