interface and implementation

why should i separate the interface from the implementation? does any body have any good material i can read about this? thanks for any help.
Any good book of COM can tell you why.

Don Box's Essential COM, for instance.

Well, COM did it because C/C++ compilers returned different results when compiling. The problem was generally observed, but they also observed that pure virtual classes were all compiled the same. Therefore, binary compatibility could be achieved by handling pointers to pure virtual classes as opposed to pointers to (implemented) classes.

But probably the main advantage (observable in COM as well) is that you can actually change one implementation for another and you don't have to recompile your application.

Example: You hire two accountants. One of them does all calculations by hand; the other one does all calculations in MS Excel. Both accountants can do the same work, but they do it differently.

You, as the boss, don't really care how Accountant X or Y does his job. You only care that the job be done. Clear separation between interface and implementation.

Translating the example a bit:

-Accountants X and Y are object instances of classes AcctX and AcctY, respectively.
-The boss (you) is the consuming application.
-The interface is the set of "commands" that the boss can issue to any accountant.
-The implementation is how a particular accountant gets the job done (by hand or by using Excel).

One of the implementations will be faster than the other, true, but that didn't force the boss to learn something new to be able to instruct either accountant (the boss did not have to be modified and recompiled).
Sorry to post here but I am new as of today and I do not see how to start a topic. My question is how do I make sure I can add a compiler to my machine? I have windows vista and I downloaded the vcMS compiler 20008. Thanks.
The "Create a topic" button is at the very bottom of the page.

Anyway, you could try just installing it and seeing if it works (maybe overnight so you don't waste time waiting for it). Maybe MS has a compilier forum for that...these forums are more for programming questions then set up questions, hehe.
oh so that is not a programming question? I thought it was basic programming LOL, very basic.
Thanks.
Last edited on
Topic archived. No new replies allowed.