GeeCON Prague 2014*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Interface & Implementation class location Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Interface & Implementation class location " Watch "Interface & Implementation class location " New topic
Author

Interface & Implementation class location

Joe Paolangeli
Ranch Hand

Joined: Apr 05, 2000
Posts: 73
This is a question for folks that create interfaces and implementing classes. Do you keep the interface and the implementing class in the same or different packages?
Ramesh Donnipadu
Ranch Hand

Joined: Sep 16, 2000
Posts: 100
I guess you can do it either way.
If you choose to write the interface in a different package, you just need to import it before using it.
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1449
I have seen it done both ways. I tend to mix interfaces and classes into the same packages but this may not be a best practice.
John


The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
Laojar Chuger
Ranch Hand

Joined: Dec 20, 2000
Posts: 111
Did you guys ever see private or protected interface?
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1449
Interfaces can only be public or default/package/friendly, ie,
public interface Example
or
interface Example
John
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Originally posted by Joe Paolangeli:
This is a question for folks that create interfaces and implementing classes. Do you keep the interface and the implementing class in the same or different packages?

It really depends on your design. If everything relating to this concept is small and local, you should probably keep them in one package. If the interface has multiple, widely differing implementations, it make mare more sense to put them in different packages. I've done projets where we create a facade and use package level protection to prevent people from going behind the facade, in thise case, the interface and implementation are in different packages.

--Mark
hershey@vaultus.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interface & Implementation class location