The separation of interface and implementation

>>> The separation of interface and implementation makes it easier to modify the code within a class without breaking any other code that uses it.

I was reading above lines from link

I have not clearly understood it clearly.

Any ideas, resources,sample code,links,  highly appreciated. thanks in advance.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Interface is just declaration of what methods object should implement

If an object implements interface it means that in response to certain query (or set of queries) it will
return value (or values) of certain type(s)

This formula implies that for the querying entity (say calling class or calling piece of code)
it is immaterial how the called object came to the result which it returns. For the calling code it is only
important that such request could be made and the result would be of expected type
So Interface allows to look at the object so to speak from the outside, to look at it as a
black box with certain properties and behaviors

On the other hand for someone who is actually writing the code of particular
class, craetes this class from the beginning, it is important to know how you would arrive at the
repsonses to the queries. Therefore, the actual code of the class
needs to contain implemenation of each method; therefore
class methods contain implementations.

Interface just states the signatuers of required methods
and is not concerned with implementation.

This is very important difference and it allows to those programmeers
who are using oibjects written by other programmers, not to dive deeply
into the mechanisms of the operations of those objects and conectntrate
on some other more high level stuff.

this is a very imporatnt distinction for Object Oriented programming, the
one which allows rather logically split the huge job of writing
a very complex applications between the programmers or even groups of programmers
who create different sets of objects, once their interfaces - so to say rules
of their interactions with each other are defined.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sathish David Kumar NArchitectCommented:
>>>>>>>> The separation of interface and implementation makes it easier to modify the code within a class without breaking any other code that uses it.

Take it example as car in ford  ...
take seat and engine  are diffrent for each and every cars. so you need to repeat the same kind of code and some changes .

so avoid that ...  create a interface as car and they have seat engine .

so if you implement the code the you no need to creat a method again and again !!
To continue on the car example above... The point is that you have code that do something with a car (i.e. build a car, sell a car,...) and you would need to have method to do so. What you want to do with an interface, is that you define the methods but the implementation may differ if the car is a Ford or a Fiat.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.