Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it acceptable for an interface definition to contain references to other interfaces?

Tags:

java

interface

I was looking at the definition of Spring's PlatformTransactionManager which contains references to TransactionStatus and TransactionDefinition, two other interfaces.

Is this acceptable in general, an interface's definition containing references to other interfaces? When is it useful?

like image 918
Abhijeet Kashnia Avatar asked Sep 14 '10 10:09

Abhijeet Kashnia


2 Answers

Yes it's acceptable. Why wouldn't it be ?

It's even better to have references to Interfaces instead of concrete classes for what it worth.

like image 180
Colin Hebert Avatar answered Nov 09 '22 04:11

Colin Hebert


It's absolutely acceptable. Sometimes types need to refer to other types - and if those types in turn represent potentially complex services, it's useful to be able to abstract out a general type, often in the form of an interface.

like image 36
Jon Skeet Avatar answered Nov 09 '22 04:11

Jon Skeet