Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is "interface"? and how to use it?

 
nick cheng
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks!
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this thread for an explaination.
 
Harathi Rao
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In one of the interviews i attended i was asked the following question:

" Abstract classes are more faster than Interfaces in implementation, then y do we go for interfaces over an abstarct class, and y in Java we find many interfaces? as almost everything is an interface."

what is the exact answer for this? My answers didn't satisfy them.

Thanks!
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I doubt that there is an "exact answer". However, this topic has been discussed on several occassion here at the Saloon. You should use the Search tool to find these threads. Using something like "interface abstract class" as the search keywords should turn up some decent results.

Keep coding!

Layne
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As for why we find so many interfaces ... Many design patterns and object oriented principles are focused on reducing dependency between classes, packages and larger grained components. They try to isolate sites of change - if this class changes often keep it away from classes that never change so we can avoid breaking the stable class and better organize our testing - and make change possible - I can introduce a new widget without modifying the thing that uses widgets. It's a fascinating area of study that repidly takes you into fairly advanced territory!

Google for "patterns in Java" to see some examples. HERE is something I put together for my team that shows some examples, too.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic