From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,b0b9a5eaad4ab6eb X-Google-Attributes: gid1164f8,public X-Google-Thread: f8c65,37e683828bae12e2 X-Google-Attributes: gidf8c65,public X-Google-Thread: 1014db,37e683828bae12e2 X-Google-Attributes: gid1014db,public X-Google-Thread: 109fba,37e683828bae12e2 X-Google-Attributes: gid109fba,public X-Google-Thread: 1008e3,37e683828bae12e2 X-Google-Attributes: gid1008e3,public From: mch24@cam.ac.uk (Martin Harvey) Subject: Re: [++] Tight coding Date: 1998/03/02 Message-ID: <6dfbs3$95g$1@lyra.csx.cam.ac.uk>#1/1 X-Deja-AN: 330165174 References: <6csl81$rb9@news-rocq.inria.fr> <34F3B7C5.5FD1@earthlink.net> <34F49435.B6307838@hda.hydro.com> <6dbgjv$lg$1@andros.cygnus.com> Organization: Pembroke College, Cambridge Newsgroups: comp.sys.dec,comp.lang.c++,comp.lang.c,comp.lang.modula2,comp.lang.modula3 Verily, peter@eepjm.newcastle.edu.au (Peter Moylan) spake thus: >I'm constantly amazed at the way the OO paradigm has taken >over so many minds. In my experience it's great for toy >programs, but gives you a complexity blow-out on any >reasonable-sized project. Admittedly a lot of my OO experience >comes in conjunction with using the Microsoft Foundation >Class library, which seems to have been designed expressly >for the purpose of convincing people that OO libraries are >evil. Nevertheless, I am still not convinced that there's >a good way to use OO techniques in conjunction with clean >programming practices. Peter, While you post plenty of excellent advice... I am slightly inclined to disagree here....! I find that OO libraries, when well written, can be great for reducing complexity. However... the reason that they introduce additional complexity is because of the subtleties involved in inheritance and polymorphism. They seem like fairly simple concepts, but when applied on a large scale, they can do very odd things. I think the secret to OO programming is to think everything through well in advance. From my experience, OO architectures can be great for data hiding and abstraction, but they really don't like ad-hoc solutions or modification. You can do lots of really subtle and neat things (especially when using "advanced" OO techniques, such as metaclasses, polymorphic construction etc etc....) and some of these techniques are very powerful, but one has to design elegantly. Alas... to many C++ programmers from a C background..... To be honest, having recently gone back to M-2 (for a few weeks) having used Delphi, I was amazed at how simple everything was. I have to confess that I found OO and event driven programming so neat, then when writing my Modula-2, I ended up using opaque and abstract data types loads, and started writing code with loads of callbacks in, to make my M-2 stuff "event driven (see IRC via DOS post!). I suspect that OO programming is very powerful... but can be badly misused. I've just written about 15,000 lines of Delphi communications code, all of which is message based and asynchronous. I wouldn't have been able to write it at all in a non OO paradigm (involving as it does implementing distributed OO protocols), and it is an order of magnitue more powerful than anything I could have written in M-2 or C given the same limit on code size. However, it's just too easy to get things wrong if you start using OO code that you 1) Didn't write, 2) don't fully understand, or 3) is poorly documented, because OO introduces subtlety in everything you do ... eg. MyObject.DoFoo(SomeObject:TObject); A simple method call to an object, supplying another object. Simple right? Wrong. 1. The method may be virtual... and thus call various other methods. 2. The parameter may be of any object type descended from TObject, this call may call some of "SomeObjects" methods, which may in turn be virtual, and call other methods back in the original MyObject.... which may be virtual & overriden etc etc. I've seen simple method calls like this do the most wierd and wonderful things ... anyway... I've run out of energy for today ... so that's my $.02. MH.