how to do examples from Head First Design Patterns, a Java book, in VBA?

drewg

Board Regular
Joined
Jul 5, 2010
Messages
67
I'm getting my feet wet with objects and started reading Head First Design Patterns after reading http://www.cpearson.com/excel/Implements.aspx
The sorting example showing the value of interfaces from cpearson.com worked, but trying to follow along in the first chapter of the design patterns book did not. I know VBA is missing inheritance, but can anyone offer some kind of Rosetta Stone or translator or a what to watch out for when trying to adapt a Java class / interface and objects examples into VBA?
Thanks for bearing with me
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Not really, but you've hit the nail of the head. I'd have thought that 90% of the patterns in that book cannot be used in VBA due to the lack of inheritance - Anytime the book indicates something is inherited, it pretty much can't be done in VBA.

Why are you trying to implement OOP in a procedural language? Seems awfully masochistic to me


footnote: There are some really horrible ways of simulating inheritance in VBA that I've seen, but drudgery and pain lay down that road ;)
 
Last edited:
Upvote 0
Thanks very much for your reply
I was very impressed by how the book explained that by moving things that change into their own classes made a program more accommodating to change, but i couldn't get their example to work because there was no way to say "Extends" in Excel.
So having an interface by itself did not fix the maintenance problem introduced by inheritance ( in the book, its a duck that can't quack).
But back in Excel, if you copied the super type, it seems to remove the advantage you are trying to create.
So the whole educational episode resolved down to I that even though i love VBA, I learned there's something I can't do with Excel.
thanks again
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top