From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6960ceaa57428e2f X-Google-Attributes: gid103376,public From: James Rogers Subject: Re: Another important feature of Ada Date: 2000/11/19 Message-ID: <3A183756.485D5911@worldnet.att.net>#1/1 X-Deja-AN: 695508289 Content-Transfer-Encoding: 7bit References: <3A12041B.BCFD8CA0@worldnet.att.net> <8uu6tf$63d$1@nnrp1.deja.com> <3A12BBC6.E3FDAB0F@averstar.com> <8v5dkm$ftt$1@wanadoo.fr> <8v78bm01p5t@drn.newsguy.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 974665467 12.74.156.54 (Sun, 19 Nov 2000 20:24:27 GMT) Organization: AT&T Worldnet MIME-Version: 1.0 NNTP-Posting-Date: Sun, 19 Nov 2000 20:24:27 GMT Newsgroups: comp.lang.ada Date: 2000-11-19T00:00:00+00:00 List-Id: "pete@nospam" wrote: > > In article , Ed says... > > > > >I agree with your point about the value of being able to compile against > >unimplemented specs - it's always been one of my favorite aspects of > >Ada. But the same effect can be achieved otherwise. > > not sure that compiling against unimplemented specs is that important. > after all, you are just checking compiler syntax errors, and checking > against any mismatched types. And you can do that in almost any > other language. In Java for example using interfaces, and in C++ using > pure virtual functions. Java's interfaces are not a good example of a tool for separating interface from implementation because they are a special case for the language. It is impossible to define a Java interface such that the interface defines all the public, default, and protected members (data and methods) defined in every class implementing that interface. Java classes can inherit from exactly one class, either one explicitly declared with an "extends" clause, or implicitly extending the Object class. At the same time a Java class may implement any number of interfaces. The term any number maps pretty closely to the Ada Natural subtype. Given that a class does not need to implement any interface, how can interfaces be a solution to the complete separation of interface and implementation. Given that any class implementing an interface extends some other class, and may implement several interfaces, how can a Java interface be a solution to this problem? It cannot. Pure virtual functions are similar to Ada abstract subprograms. This is not the technique commonly used in C++ to separate interface from implementation. The commonly used technique is the preprocessor. The interface is commonly defined in the C++ header files, while the implementation is defined in the C++ source files (.cpp or .C files). The problem with using C++ header files is that the C++ language has no restriction upon the contents of a header file. It is possible to mix interface and implementation in a header file. Only programmer discipline can prevent such a mixing. > And in practice, it is only after running the program against the > actual implementation that one finds for sure if the interface is > the right one, also many times the interface is changed as development > goes on. > This of course reveals a process problem in several development projects. The reason for changing interfaces is most often because insufficient analysis and design work was done before beginning implementation. The only time I have seen it necessary to change the interface definitions has been when new requirements are levied on the project after analysis and design is complete. This, again, is a process problem. The separation of interface and implementation is still useful in this case as it allows the design team to clearly identify the current design problems and develop design alternatives. Many times the interfaces do not need to be changed. Instead, some new packages may be needed. Note that performance issues have no impact upon the separtation of interface and implementation since they are handled purely in the implementation. Jim Rogers Colorado Springs, Colorado