Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 300
Default Why use Class Modules?

I've written a large pricing application in Excel. Lots of VBA and User
Forms, but very concisely written. I need to add a feature written by
someone else. This other programmer is not known for concise code. My
question here is why has he used Class Modules instead of simply having all
the code in a regular Module.

Don <www.donwiss.com (e-mail link at home page bottom).
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Why use Class Modules?

A class module is used to encapsulate a variety of data about a particular
entity into a single entity. For example, imagine you are writing an
application that does something with employees. You could create a class
called CEmployee that would have data items for name, address, phone, etc. A
class can also contain methods (Subs and Functions), so your CEmployee class
might have a method that prints the employee's paycheck. In your
application, you would create a new instance variable of the CEmployee class
for each employee you are dealing with. By using a class to represent one
employee, you can use a single variable to represent all the various
attributes of an employee. In a large and complicated application, it is
MUCH easier to deal with one variable, a variable of type CEmployee, that
wraps up all the information than it is to deal with many separate,
unrelated variables. Without classes, you'd probably end up with a number of
arrays that would have to be kept in sync with one another, a task that can
quickly get quite complicated.

This other programmer is not known for concise code.


My experience over the years has been that using classes doesn't have a
profound effect on the number of lines of code in a project. In the big
picture, classes neither increase nor decrease the number of lines of code
in a project (but using lines of code as a measure of anything is rather
inane). Classes can have a very positive effect by simplifying and
streamlining the logic of the application.

For a much more in depth look at classes with example, see
www.cpearson.com/Excel/Classes.aspx


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Don Wiss" wrote in message
...
I've written a large pricing application in Excel. Lots of VBA and User
Forms, but very concisely written. I need to add a feature written by
someone else. This other programmer is not known for concise code. My
question here is why has he used Class Modules instead of simply having
all
the code in a regular Module.

Don <www.donwiss.com (e-mail link at home page bottom).


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Class modules: parametrize class object fields Jean-Pierre Bidon Excel Programming 11 August 31st 06 02:49 PM
Basic question - modules and class modules - what's the difference? Mark Stephens[_3_] Excel Programming 9 May 8th 05 11:48 AM
Class Modules mark Excel Programming 7 April 14th 04 10:10 PM
Class modules pk Excel Programming 2 October 3rd 03 03:45 AM
Class Modules vs Modules Jeff Marshall Excel Programming 2 September 28th 03 07:57 PM


All times are GMT +1. The time now is 06:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"