On 30/05/2017 9:52 PM, Charles Mills wrote:
You're trying to scare the poor man!

After I learned OO, I realized the problem in trying to communicate the 
concepts.

- The easy-to-grasp explanations are stupid: Animal is a class. Dog and Cat are 
child classes of Animal. Fido is an instance of Dog. You could have an 
inherited public overridden method Speak() and say myAnimal.Speak() and if it 
were a Dog it would bark and if it were a Cat it would Meow ...

Agreed. Inheritance should generally be avoided anyway. It has it's place but composition should be preferred 9 times out of 10. Inheritance is tightly coupled and can become incomprehensible once it gets a few layers deep.

- The real problems that are solved by the significant features are too hard to 
explain in a simple tutorial. I solved a problem the other day with a very 
sparsely-implemented virtual polymorphic method -- but it would take me an hour 
to explain what the problem was.

Polymorphism is the key principle and you don't need an OO language to use it. Any language with function pointers can implement polymorphism. A case in point is the z/OS C stdio runtime which supports many different types of data source. fopen() is the factory function which populates the read/write (virtual) function pointers in the FILE structure. There's no reason why you can't write OO code in assembler. I see lots of assembler code with constitutional logic littered throughout which call different functions depending on some type which would benefit from an OO design.

Charles


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of David Crayford
Sent: Tuesday, May 30, 2017 5:23 AM
To: [email protected]
Subject: Re: Question about C++

This might bewilder you some more ...

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to