Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

interfaces & abstract classes

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is meant by 'you can vary interface of class independent of implementation'.
and 'client only sees interface not implementation'
These are excerpts from UML Distilled.
Does anyone know
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The interface are the public methods of a class. It is what other classes see when they look at your class. The implementation is the actual code behind the interface. As long as you don't change the method signature of your public methods, you can do anything you want inside your methods and I will still be able to compile and execute my code.
 
Marshal
Posts: 16631
278
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Has to do with the concept of Encapsulation.
When you write an object that implements an interface, you are making a promise to "clients" (anybody/anything that interacts with the object that implements the interface) that you will provide the services defined in the interface.
The clients don't care exactly how you implement the service. As long as the end result is the same, you are free to change how your object does the actual work.
It's like using a telephone: you dial a few numbers, you expect to be connected to a specific person. All you, the user/client, care about is that you have a dial tone, a receiver, and a way to dial numbers and that you are patched through to the right person. You don't care about the mechanics of how the connection is made, whether it be by satellite, GSM, PCS, fiber optics, or plain old twisted pair wires, digital or analog, etc. The phone is your interface to the phone company, which provides the service of connecting you to somebody else's phone.
J.Lacar
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice analogy!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic