Linked by Hadrien Grasland on Wed 15th Jun 2011 07:32 UTC, submitted by ebasconp
General Development "The recently finished C++ ISO standard, with the working name of C++0x, is due to be published this summer, following the finishing touches to the ISO spec language and standards wonks agreed upon in March."
Permalink for comment 477644
To read all comments associated with this story, please click here.
RE[10]: Basically, awesome
by FealDorf on Sat 18th Jun 2011 00:35 UTC in reply to "RE[9]: Basically, awesome"
FealDorf
Member since:
2008-01-07

Why don't you finish your sentence? What happens when some code that expects the changed A2 is given an old C1 that doesn't have the change?

Um, I didn't say "and.." at any point. My bad though, I should've elaborated.

And how is that an advantage to have C1 drift away from A2? I guess C1 being an implementation of A2 was motivated by a need. What happens to that need?

The advantage is that there's no real disadvantage in exchange for improved flexibility.
The need for classes themselves are because you want to construct objects that adhere to an interface.
Interfaces exist to facilitate modularity i.e., they exist in different modules.


The way I can see (right now, atleast), the only case where "C1 implements A2; A2 changes" is an issue is when Object of C1 is passed to a method accepting A2 (say, M1) in an invocation (I1). Then:
#1 I1 and M1 are in same module (which implies recompilation either way)
#2 I1 and M1 are in different modules (in which case, only I1 needs to be changed and not C1 and I1)

Mind you, I'm not saying "there's no case where a class MUST implement an interface" -- however that is better moved to compile-time annotations than make a language restriction.

I think you are just struggling to justify the unjustifiable. Give us a working example of what you are advocating.

I don't think a working example actually exists where interface hierarchy *is* required. However, a simple example for me would be:

class LinkedList implements List, Stack, Queue;


In reality though a LinkedList does NOT have to implement Stack or Queue. Also, even the slightest change necessitates an unneeded recompilation. On top of it; size, dependency and complexity of the class increases.

Edited 2011-06-18 00:37 UTC

Reply Parent Score: 1