Slimelite BBS

Re: VB/TBV/VBC++ (was Cop

Back to DRIVING

From Pat Winstanley · 1996-04-06 11:03 · #69244 in DRIVING

In reply to Re: VB/TBV/VBC++ (was Cop by Paul Walker

Hi Paul,

Saturday April 06 1996 21:15, Paul Walker wrote to Peter Dalton:

 PW> [What's OO?]
 PW>> Usually, it's Object Orientated - ie, you can define
 PW>> and use objects ;-)
 PD>> ye-es...but why's that so good?
 PW> Er... right, I'll be off now, see ya... ;)

ROFL!

Actually, while your explanation was clear (and correct) as far as it went, I think there is much more to objects than simply re-usability. The whole concept seems to imply a completely different way of looking at things.

From what I can gather the power of inheritance seems to be crucial. For instance I'm writing a suite of educational/puzzle games as a vehicle to learn Delphi with, and one of the features that will crop up regularly is a panel with 26 buttons on it - each one for a letter of the alphabet. However I also need a similar panel but calculator pad style, and then again, one representing a keyboard. Now each of these panels does essentially the same thing - displays a set of choices, then when a choice is clicked, sends a message out to say which value has been chosen.

From the point of view of the panel it doesn't matter what that value represents (like when the phone rings, the phone doesn't care who is calling, and it's up to the person/thing receiving the call to recognise and deal with whatever is coming out of the phone line.

So (and bear in mind this is what an OO mad friend is teaching me) what I need to do to OO my code is make my panel-with-buttons as generic as possible, as a parent, then create children of that simple panel. The parent panel will have the ability to hold buttons, those buttons can be clicked, and a message passed to say one has been clicked. The alpha, numeric, and keyboard panels I create inherit the basic functionality, and have some additional bits of their own added - tailored to the particular function in mind.

In the case of the project I'm tackling, this re-usability and inheritance will be extremely useful, and time-saving in the long run as I now have a set of pre-written objects (methods, properties and all) sitting in the toolbar as custom components that I can just drop onto a form and test for messages coming out.

In a single application it wouldn't be worth the effort unless I had a real reason to expect to use the objects in the future in other projects.

OK, that was probably a trivial example, but a real world one.

From what I've learned, the idea is to take a basic idea, generalise it as far as possible, then use that underlying engine to inherit and adapt from. Real black-box stuff! Or as someone else I heard put it, "Keep it simple, stupid".

Pat

---
 * Origin:  Pierless, Wigan, UK. [01942-749012 (cable)]  (2:250/107.99)