- Virtual functions - 18 Updates
- EXAMPLE - 6 Updates
- Simple Proxy Collector... - 1 Update
Tim Rentsch <txr@alumni.caltech.edu>: Apr 04 10:42PM -0700 > concrete members would have sufficed. > There may be ways around this, or a better way to reason about such > code, but I haven't found it yet. (But I know you're happy with it.) I find these comments about virtual functions and polymorphism[*] interesting. I started on C++ quite a while ago, but even so had been using polymorphic messaging for about a decade before that. For me class hierarchies and (what C++ calls) virtual functions pretty much pop up naturally, without my having to seek them out especially. (That is not to say they don't benefit from being revised, of course they do.) I speculate that starting with C++ as a first "OOP" language makes it harder to acquire the OOP mindset. No evidence, mind, besides this one data point, but it is still an interesting conjecture. [*] The programming language community usually refers to things like virtual functions as just plain polymorphism, ie, without any "run-time" modifier. Other kinds of polymorphic constructs, eg overloaded functions or templates, are usually referred to as "ad hoc polymorphism". (This is assuming the terminology hasn't changed since I was active in the field, which it may very well have.) |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Apr 05 04:46PM +0200 On 05.04.2018 07:42, Tim Rentsch wrote: > "ad hoc polymorphism". (This is assuming the terminology hasn't > changed since I was active in the field, which it may very well > have.) It all depends on the context. The C++ standard defines polymorphic as a formal term (in C++17 §1.8/1 and §10.3/1), for a class meaning that it has one or more virtual functions. That's what's meant by "polymorphic class" or "polymorphic object". The more general meaning of polymorphism is that the same source code can have different detailed effects depending on the types involved in an invocation/instantiation of it. For that C++ supports polymorphism resolved at compile time, called static polymorphism, and polymorphism resolved at run time, called dynamic polymorhism. The ¹Wikipedia article about polymorphism supports your view of the terminology, but seems to be at odds with most every article about it for programmers. From that I conclude that the term "ad hoc polymorphism" is almost exclusively used in academia. I believe that academia is by nature very conservative, often failing to adjust. Cheers & hth., - Alf ¹ https://en.wikipedia.org/wiki/Polymorphism_(computer_science) |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Apr 05 06:01PM +0100 On 05/04/2018 15:46, Alf P. Steinbach wrote: > For that C++ supports polymorphism resolved at compile time, called > static polymorphism, and polymorphism resolved at run time, called > dynamic polymorhism. Types cease to exist after compilation: it is all just text in the text segment: theoretically a compiler compiling a C++ program utilizing vtables can generate the same machine code as a totally different language compiler which has no such concept as vtables and virtual functions which means that "runtime polymorphism" is a nonsense as it doesn't actually exist. /Flibble -- "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." </troll> |
legalize+jeeves@mail.xmission.com (Richard): Apr 05 05:21PM [Please do not mail me a copy of your followup] Tim Rentsch <txr@alumni.caltech.edu> spake the secret code >as a first "OOP" language makes it harder to acquire the OOP >mindset. No evidence, mind, besides this one data point, but >it is still an interesting conjecture. Anecdotally, this is my experience as well. My first OOP language was C++ and it wasn't until I started practicing TDD that I felt the benefit of SOLID design principles. >"ad hoc polymorphism". (This is assuming the terminology hasn't >changed since I was active in the field, which it may very well >have.) It's common to refer to template genericity as static polymorphism in C++ and the typical virtual method style polymorphism as dynamic or run-time polymorphism. -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://computergraphicsmuseum.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Apr 05 06:28PM +0100 On 05/04/2018 18:21, Richard wrote: > Anecdotally, this is my experience as well. My first OOP language was > C++ and it wasn't until I started practicing TDD that I felt the > benefit of SOLID design principles. TDD is cancer. Designing software by fixing failing tests is no way to design software. /Flibble -- "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
Paavo Helde <myfirstname@osa.pri.ee>: Apr 05 09:07PM +0300 On 5.04.2018 20:28, Mr Flibble wrote: > TDD is cancer. Designing software by fixing failing tests is no way to > design software. Well, evolution has done exactly that and designed things like me and you;-) Not sure yet if this is a total failure or not. Of course, things like giraffe's laryngeal nerve ("https://rationalwiki.org/wiki/Laryngeal_nerve") are not so neat, but they are there in the codebase and not going anywhere. Also beware that our new neural net overlords are being designed by a similar trial-and-error approach (although the process is called "training" by some reason), so you should better get used to the idea before they find you dispensable. Cheers Paavo |
Ian Collins <ian-news@hotmail.com>: Apr 06 07:24AM +1200 On 04/06/2018 05:28 AM, Mr Flibble wrote: >> benefit of SOLID design principles. > TDD is cancer. Designing software by fixing failing tests is no way to > design software. Maybe, so it's a good thing that TDD isn't designing software by fixing failing tests. -- Ian |
legalize+jeeves@mail.xmission.com (Richard): Apr 05 07:38PM [Please do not mail me a copy of your followup] >On 5.04.2018 20:28, Mr Flibble wrote: >> TDD is cancer. Designing software by fixing failing tests is no way to >> design software. I knew there was a reason you were in my KILL file... -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://computergraphicsmuseum.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Apr 05 08:46PM +0100 On 05/04/2018 20:24, Ian Collins wrote: >> design software. > Maybe, so it's a good thing that TDD isn't designing software by fixing > failing tests. It is tho. /Flibble -- "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Apr 05 12:51PM -0700 On 4/5/2018 10:28 AM, Mr Flibble wrote: >> benefit of SOLID design principles. > TDD is cancer. Designing software by fixing failing tests is no way to > design software. Imvho, fixing a failing test can be beneficial. ;^) |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Apr 05 08:55PM +0100 On 05/04/2018 20:51, Chris M. Thomasson wrote: >> TDD is cancer. Designing software by fixing failing tests is no way to >> design software. > Imvho, fixing a failing test can be beneficial. ;^) I have no problem with unit tests which are great for finding regressions but I do have a problem with designing software by fixing smallest testable units (i.e. functions) which is what TDD is all about. Unit tests should drive continuous integration NOT design. /Flibble -- "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
Ian Collins <ian-news@hotmail.com>: Apr 06 08:10AM +1200 On 04/06/2018 07:46 AM, Mr Flibble wrote: >> Maybe, so it's a good thing that TDD isn't designing software by fixing >> failing tests. > It is tho. Tests don't design themselves... -- Ian. |
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Apr 05 01:13PM -0700 On 4/5/2018 12:55 PM, Mr Flibble wrote: > regressions but I do have a problem with designing software by fixing > smallest testable units (i.e. functions) which is what TDD is all about. > Unit tests should drive continuous integration NOT design. Humm... That is difficult for me to disagree with. The design is the design. The tests should aid in making sure the design is working as expected. |
Ian Collins <ian-news@hotmail.com>: Apr 06 08:22AM +1200 On 04/06/2018 08:13 AM, Chris M. Thomasson wrote: > Humm... That is difficult for me to disagree with. The design is the > design. The tests should aid in making sure the design is working as > expected. If you can sider the test to be part of the design (the detailed design if you like), it is logical to write them before the code. So just as you start out with a requirement the code does not meet, you start out with a test its does not pass. Once it meets the requirement, the test passes. -- Ian. |
Vir Campestris <vir.campestris@invalid.invalid>: Apr 05 09:35PM +0100 On 05/04/2018 18:01, Mr Flibble wrote: > language compiler which has no such concept as vtables and virtual > functions which means that "runtime polymorphism" is a nonsense as it > doesn't actually exist. After compilation all those nice high level abstractions have disappeared in a cloud of assembler (or not even that, depending on your compiler). And yet, runtime polymorphism does exist. A C program could choose to put a function pointer into a struct, and have the calling program use the function pointer. That's runtime polymorphism. You could do it in assembler if you were that perverse. In fact I have a vague memory of doing just that for an API many MANY years ago, back when assembler efficiency mattered more than developer man hours. (If there were lots of these you might want to put all the pointers in a table shared between similar structs. You could call it a vtable.) Andy |
legalize+jeeves@mail.xmission.com (Richard): Apr 05 09:43PM [Please do not mail me a copy of your followup] Ian Collins <ian-news@hotmail.com> spake the secret code >you start out with a requirement the code does not meet, you start out >with a test its does not pass. Once it meets the requirement, the test >passes. This. Maybe people would understand this better if it were called Design Driven Development instead of Test Driven Development. The main activity is a design activity, not a testing activity. -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://computergraphicsmuseum.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Apr 05 10:47PM +0100 On 05/04/2018 22:43, Richard wrote: > Maybe people would understand this better if it were called Design > Driven Development instead of Test Driven Development. The main > activity is a design activity, not a testing activity. Bullshit. TDD isn't design driven in the slightest. /Flibble -- "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Apr 05 10:49PM +0100 On 05/04/2018 21:35, Vir Campestris wrote: > ago, back when assembler efficiency mattered more than developer man hours. > (If there were lots of these you might want to put all the pointers in a > table shared between similar structs. You could call it a vtable.) I suggest you scroll to the end of my post; past the .sig. /Flibble -- "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
Tim Rentsch <txr@alumni.caltech.edu>: Apr 04 11:27PM -0700 > because you can, rather than because you should. Still, I'd say the > difference between a median of 10 and a median of 20 is more a quibble > than a qualitative change. If you actually measured you might find the numbers are smaller than you think. For example, I took the old BSD 'vi' sources and ran statistics on them. With nearly 16,000 lines of source, and just over 190 functions, the the median function length was 7 lines, the average just over 20, and the (only) 51 line function coming in at 92+ percentile. And this happened despite there being a dozen or so long functions, including eight over 80 lines, the second-to-last of which about 125 lines, and the largest being a whopping nearly 900 lines. The average and the median are small not because there are no long functions but because there are lots of little ones. Also there can be paradoxical effects - for example if we took the 900 line function and split it into nine functions of 100 lines each, the average would go down, but the median would go up, and the percentile for 50 lines would also go down. The difference between a median of 10 and a median of 20 might seem small quantatively, but if you looked at two code bases with these median sizes I suspect you would find them to have vastly different characters. For example, in another code base, with 60 lines being less than 90th percentile, and more than 20 functions (out of 675 total) over 100 lines, the average was still only 24 lines, and the median 12. It would take a huge change to get that median up to 20. |
Paavo Helde <myfirstname@osa.pri.ee>: Apr 05 08:29PM +0300 On 5.04.2018 9:27, Tim Rentsch wrote: > just over 190 functions, the the median function length was 7 > lines, the average just over 20, and the (only) 51 line function > coming in at 92+ percentile. Uh-oh. Just yesterday I had a code review of a 239-line function, containing a 187-line lambda in the middle. The author was not happy at all when I told him this is no good. He said he cannot think up names for smaller functions and anyway he finds it easier to follow the program logic if it is all nicely linear in a single function. I am not hoping he will be making 10-line functions, our modest goal is 50 lines at the moment. Cheers Paavo |
legalize+jeeves@mail.xmission.com (Richard): Apr 05 07:37PM [Please do not mail me a copy of your followup] Paavo Helde <myfirstname@osa.pri.ee> spake the secret code >all when I told him this is no good. He said he cannot think up names >for smaller functions and anyway he finds it easier to follow the >program logic if it is all nicely linear in a single function. So presumably he hates this example? <https://www.industriallogic.com/xp/refactoring/composeMethod.html> -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://computergraphicsmuseum.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
Vir Campestris <vir.campestris@invalid.invalid>: Apr 05 09:35PM +0100 On 05/04/2018 18:29, Paavo Helde wrote: > I am not hoping he will be making 10-line functions, our modest goal is > 50 lines at the moment. 50 is short. I aim to keep the entire function on screen. As screens have grown from 25 lines my functions have grown a little too. Andy -- Work computer: 1600 pixels in portrait mode. Perhaps 100 lines? |
Paavo Helde <myfirstname@osa.pri.ee>: Apr 06 12:23AM +0300 On 5.04.2018 22:37, Richard wrote: >> program logic if it is all nicely linear in a single function. > So presumably he hates this example? > <https://www.industriallogic.com/xp/refactoring/composeMethod.html> Not sure. Maybe. Or maybe not. He has never given a straight answer to any questions I (or anybody else AFAIK) have asked, so in last years I have stopped asking him anything. To give him credits, he actually produces working code far from trivial, albeit very slowly, and there are very few bugs in the final code. So, if the code works, and there are no bugs, then why could it not be a 239-line function? I guess now he will spend the next 2 weeks on refactoring this function into 50-line functions. I'm starting to doubt my code review decisions... |
legalize+jeeves@mail.xmission.com (Richard): Apr 05 09:41PM [Please do not mail me a copy of your followup] Paavo Helde <myfirstname@osa.pri.ee> spake the secret code >To give him credits, he actually produces working code far from trivial, >albeit very slowly, and there are very few bugs in the final code. I too used to produce code this way before TDD. It's not that I couldn't get the bugs out from careful manual testing, it's that the time between creating the bug and fixing the bug was orders of magnitude longer than when I practice TDD. In other words, my error rate has remained rather consistent but the time between creating and fixing a bug goes from never/months/weeks/days/hours to seconds. >So, >if the code works, and there are no bugs, then why could it not be a >239-line function? It's fine if it will never need to be modified ever again. -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://computergraphicsmuseum.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Apr 05 12:50PM -0700 On 3/29/2018 9:30 PM, Chris M. Thomasson wrote: > run full steam ahead, while the writers do not interrupt them. This can, > increase concurrency and overall performance, and can get rid of certain > bottlenecks especially if the problem is mostly read based. Think about it.... Being able to have a shi% load of reader threads concurrently iterating a shared data-structure that cannot be blocked by any concurrent writer threads. I can think of many situations where this is a desirable feature... Can anybody else think of one? |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment