interface specification returning defined classes

I am looking at an interface specification with the hopes of potential developing a new implementation for it.

Many of the methods return classes that were designed by the specification developer. I can understand you may want to "hard wire" classes in there if there is a real need to tie parts of an interface to a certain implememntation, but in my case the objects are fairly trivial. Some are returning nothing more than a list of errors/warnings.

The return type for these methods should be interfaces not classes, right?

Any adice would be great. I have never developed to an interface spefication before.....

(I have to use this specification + their implementation is a mess. If I use this class, I'll have to use others.. which lead to others.. and others.. blah,blah,blah... Hardly the flexible achitecture I envision when I think of interface specifications.)

[913 byte] By [mbgiord] at [2007-9-30 7:13:31]
# 1

> Many of the methods return classes that were designed by the specification developer.

Do you mean the return class types? Note: a method can return a class. e.g. Class.forName(String)

> I can understand you may want to "hard wire" classes in there if there is a

> real need to tie parts of an interface to a certain implememntation, but in my case the objects are fairly

> trivial. Some are returning nothing more than a list of errors/warnings.

> The return type for these methods should be interfaces not classes, right?

In most cases, a class declaration can be replaced with an interface. Only constructors cannot be replaced. You may also want to change the parameters to the methods to make them interfaces.

> Any adice would be great. I have never developed to an interface spefication before.....

It is must the same as a class development. Define an interface first which has all the methods you might have given the class. Then create a class which implements it.

If you have an existing class, rename it and create an interface with the name the class had. Then make the class implement the interface. This is what Eclipse does when recfactoring.

>

> (I have to use this specification + their

> implementation is a mess. If I use this class, I'll

> have to use others.. which lead to others.. and

> others.. blah,blah,blah... Hardly the flexible

> achitecture I envision when I think of interface

> specifications.)

I don't understand the problem. You may find that tools will help you refactory your code. The problem can be to know when to stop... :)

Peter-Lawrey at 2007-7-1 23:32:09 > top of Java-index,Other Topics,Patterns & OO Design...