Advantages of classes

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Advantages of classes

Post by agibsonsw »

Hello. Visual Basic 6 and Excel.

I understand the benefits of Object Oriented Programming in terms of modelling a complex system
and the use of encapsulation to allow several programmers to re-use classes/ objects without concern
for the internal workings of these.

Someone has a monte carlo model in VB6 which manipulates data from an Excel workbook and does make
use of classes. The code for this model prints to around 80-100 pages. I haven't been able to study the code
yet but have been asked to discuss the benefits of creating classes.

I think this is, in reality, quite a small model. What might you advise? Can there be benefits in using classes
for such a (what I believe to be) small model?

I understand it might be tricky to comment without further details, but would appreciate general comments
at this stage.

Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
Jan Karel Pieterse
Microsoft MVP
Posts: 656
Joined: 24 Jan 2010, 17:51
Status: Microsoft MVP
Location: Weert, The Netherlands

Re: Advantages of classes

Post by Jan Karel Pieterse »

Duh, just wrote a nice elaborate reply and then after I hit submit, the connection went haywire.
Teaches you to hit controlA, controlC before clikcing submit.

I like classes because they can hide complexity. Your code in the main program flow (the business logic part) becomes easier to understand.

I like this article about OOP in VB6:
http://www.visualbasicbooks.com/progVB6samplepg1.html
Regards,

Jan Karel Pieterse
Excel MVP jkp-ads.com

User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Advantages of classes

Post by StuartR »

Jan Karel Pieterse wrote:...I like classes because they can hide complexity...
I like classes because they can simplify testing.

You can test all the classes using a wide range of inputs and outputs without needing the complete application.
StuartR


User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Advantages of classes

Post by agibsonsw »

Thank you for these responses (and the link). Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.