• Post Reply Bookmark Topic Watch Topic
  • New Topic

When to use a Interface when designing a software system?  RSS feed

 
Sajith Eashan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is more towards software design.
When should we use a java interface when designing a software system
- is it when we need to support multiple implementations of some functionality or,
- is it because the implementation of a functionality is unknown and it could vary in different contexts.
Please some one help!
 
Campbell Ritchie
Marshal
Posts: 56227
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say both, yes. you should use interfaces a lot. Look at my example from three weeks ago, and the link to an older post there. Examples how engine and plant interfaces can be created, and how the plant interface could be reused and altered three years later.
 
Victor Ramen
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look carefully, you will see both the scenarios are similar in nature. So both are valid reasons for interface
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!