> There's no reason why you can't write OO code in assembler. And there's no reason you could not write OO code by keying the bits in through a debugger.
The point of the OO constructs is not that there is no other way to do things. Obviously, any object program that can be produced by a compiler could have been written in HLASM. The point of OO constructs is never having to say "was there something I was supposed to call when I was finished with this record (DSECT, struct, class, ...)?" What was its name? Where is the pointer to it? What are the calling parameters? Or worse, I just realized I am going to need a cleanup routine for this record. Now I have to go back and make sure that every piece of code that uses it gets modified to call the cleanup routine. You just delete the class and if it has a destructor, it gets called. Voila! Charles -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of David Crayford Sent: Tuesday, May 30, 2017 7:46 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Question about C++ 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. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN